Simple Way to Rename File Using Excel

I often have the need to modify a large amount of filenames, and I have often found it easiest to turn to Excel and a simple bash script.

Combine this formula with a sequence number and you have a very easy way to rename a massive amount of files and keep the filenames unique.

 =concatenate("cp ",char(34),A1,char(34)," ",char(34),"renamed/", B1,char(34))

cp "oldfilename" "renamed/newfilename" 

  1. Drag that formula down the entire column.
  2. Copy the column to a text editor and save as 
  3. Open a terminal/console and change to the directory containing the files you wish to rename.
  4. If you haven't made a directory called renamed, type mkdir renamed. 
  5. Run bash 

Generate Blank Media

Sometimes I have the need to generate truly blank/empty media on demand. Here are some solutions I found using ffmpeg and imagemagick:

-30 Seconds of blank/empty audio:
    ffmpeg -ar 48000 -t 30 -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero -acodec libmp3lame -aq 4 blank.mp3

-30 seconds of blank/empty video:
    touch 1.txt && convert 1.txt -page Letter 1.png && ffmpeg -loop 1 -i 1.png -c:v libx264 -t 30 -pix_fmt yuv420p -aspect 16:9 blank.mp4 && rm 1.*

-5 page blank/empty pdf:
    for f in {1..5}; do touch temp.txt && convert temp.txt -page Letter temp.$f.png; done && convert temp.*.png blank.pdf && rm temp.*

-Blank/empty png file:
    touch 1.txt && convert 1.txt -page Letter blank.png && rm 1.txt

Remove Solid/Blank Images

In my work role, I need to programmatically clean up blank images mixed in with millions of usable images. For this, I turned to Python and PIL:

from PIL import Image
from sys import argv

script, filename = argv

img =
colors = img.getcolors()

if colors:
    if len(clrs) == 1:
        print str(filename)+": "+"solid color, remove"
    print str(filename)+": "+"has multiple colors, keep."

Corrupt PDFs

As a digital/media asset manager, corrupt files are the bane of my existence.

To programmatically find corrupt pdf files, I landed with the following utilizing pdftotext from xpdf.

for f in *.pdf; \
do pdftotext -q -f 1 -l 2 $f $f.txt; \
err=$?; \
if [ $err -ne 0 ]; then mv $f _failed_$f; \
elif [ $err -eq 3 ]; then mv $f _locked_$f; \
else rm $f.txt; fi;