Renaming all files in a folder using the folder name 0 ▲ Thomas Rigby 17 hours ago · Tech · hide · 0 comments I find myself doing this every month so I find myself Googling this every month so, in the spirit of "write about it so you never forget it", I decided to write it down. And, who knows, it might be useful for you too. When I get my photography scans back from the lab they arrive named with a sequential number that is neat but useless. ThomasRigb036944├── 000001.JPG├── 000007.JPG├── 000008.JPG...└── 000030.JPG The associated Field Notes all have a standard naming convention of "Camera Name plus ISO Date": Minolta SRT303 2026-07-09. When I share my images on my website, the original file is copied into the repo which results in even less helpful files names like 000001 (4).JPG. So, I have added this function into my .bash_functions file (remembering, naturally, to source ~/.bashrc!) mvff() { for f in *; do [ -f "$f" ] && mv -- "$f" "$(basename "$PWD")-$f" done} [ -f "$f" ] checks that we're actually looking at a file, not a directory. If it's not a file, the && short-circuits and we… No comments yet. Log in to reply on the Fediverse. Comments will appear here.