I wanted to download a 50gb file, from an internet archive. It was downloading up to 300kb/s and it was going to take days. So I wrote a script to download the files in chunks, and upload to Google Drive without caching and filling up my 20GB server. I now have files .000 to .082.
I would like to open this in 7z, but I was a bit careless and started with 000 instead of 001, I'd rather not combine them first, so how would I bulk rename these files to increment by 1, so that I get file exts like 001,002,003?
I tried opening them in 7z, but it only reads the .000 file.
I have access to windows and linux, I tried Bulk File Renamer Utility, for windows but it doesn't seem to like incrementing file extentions by using its Numbering (10) is there a way to do it in Bulk File Renamer Utility, or otherwise how would I got about using the linux command line to rename them all?
1 Answer
This one-liner should work. Tested on macOS High Sierra (10.13.6).
It works by using ls -r to list files in reverse order, and then—via the magic of math—just adding +1 to each file extension.
The script assumes that you have files named with a pattern such as this:
test.000 test.001 test.002 test.003 And will rename them as follows when done:
test.001 test.002 test.003 test.004 Here is a “dry run” version that will simply echo the command for your review:
ls -r | while read f; do echo mv "${f}" "${f%.*}.$(printf '%03d' $(expr ${f##*.} + 1))"; done And just remove that echo to get it to run and do it’s thing like this:
ls -r | while read f; do mv "${f}" "${f%.*}.$(printf '%03d' $(expr ${f##*.} + 1))"; done 2