Ubuntu – I cannot rename files in bulk using ubuntu’s rename feature

batch-renamerename

I cannot rename files in bulk using ubuntu's rename feature. The files are on a NTFS partition.

I want to rename files that look like this:

whatever pic george.jpg
tacoma narrows bridge.jpg
green bottle.jpg

to:

filename (1)
filename (2)
filename (3)

And I cannot do this at all. I don't want to use the command line either. So I can permanently erase files after I have encrypted them without exposing their contents to people who use a file recovery tool.

I also don't want a method that takes days or months to rename the file. That is, rename one file at a time. So if I have hundreds of files to rename, this won't be a option. I want to give a each file the same name and numbered in order like shown above.

Pyrenamer is not an option for me, unless you can find how to do that in PyRenamer.

Best Answer

You can use the rename command, which is usually included in a default installation:

rename 's/.*/sprintf("filename (%d)", ++$ENV{c})/e' *

This would do precisely what you asked for. Use the -n flag if you want to do a test first:

rename -n 's/.*/sprintf("filename (%d)", ++$ENV{c})/e' *

This assumes that the environment variable c is undefined, which will cause the count to start from 0. If you want to be extra safe, you could call it like this:

c=0 rename -n 's/.*/sprintf("filename (%d)", ++$ENV{c})/e' *
Related Question