So, say, I have a directory with a bunch of files like g.txt, where g.txt was last modified on, say, June 20, 2012.
How would I batch-rename all of the files (like g.txt) with the last modified date of June 20, 2012 appended on the end?
|
|
|
Quick-and-dirty Bash one-liner to rename all (globbed) files in the current directory from
An enterprising Bash nerd will find some edge case to break it, I'm sure. :) Obviously, this doesn't do desirable things like checking whether a file already has something that looks like a date at the end. |
|||||||||||||||||||
|
|
here's a version of goldschrafe's one-liner that:
|
|||
|
|
|
Obligatory zsh one-liner (not counting the one-time loading of optional components):
We use the
|
|||
|
|
|
As I understood we don't know beforehand what is the modification date. So we need to get it from each file, format the output and rename each file in a way so that it includes the modification date in the filenames. You can save this script as something like "modif_date.sh" and make it executable. We invoke it with the target directory as the argument:
Where "txt_collection" is the name of the directory where we have all the files that we want to rename.
|
|||||||||||
|