Here is what works:
#!/bin/bash
for i in `seq 20 42`;
do
file="Voice "0${i}.m4a
mv "$file" "$file-$(stat -c %y "$file"|awk '{print $1}')"
done
I suspect there are better ways, but this will do for now...
thanks
On 11/30/2015 07:49 PM, Robert Moskowitz wrote:
On 11/30/2015 07:21 PM, Gordon Messmer wrote:
On 11/30/2015 03:50 PM, Robert Moskowitz wrote:
Now I want to rename these files, which are all lectures to have the
date of creation/lastmodified in the file name.
Does the date require a specific format?
You could:
mv "$file" "$file-$(stat -c %y "$file")"
Not quite as the script:
#!/bin/bash
for i in `seq 20 42`;
do
file="Voice "0${i}.m4a
mv $file "$file-$(stat -c %y "$file")"
done
is producing:
mv: target ‘Voice 036.m4a-2015-05-07 06:51:59.000000000 -0400’ is not
a directory
mv: target ‘Voice 037.m4a-2015-05-08 06:56:27.000000000 -0400’ is not
a directory
mv: target ‘Voice 038.m4a-2015-05-20 06:55:35.000000000 -0400’ is not
a directory
mv: target ‘Voice 039.m4a-2015-05-21 06:50:57.000000000 -0400’ is not
a directory
mv: target ‘Voice 040.m4a-2015-05-22 06:56:27.000000000 -0400’ is not
a directory
mv: target ‘Voice 041.m4a-2015-05-26 06:56:11.000000000 -0400’ is not
a directory
mv: target ‘Voice 042.m4a-2015-05-27 06:54:43.000000000 -0400’ is not
a directory
so I need to take only the date from the stat.
Or if you want to define your own (and assuming no file names contain
quote characters):
find $files -type f -printf 'mv "%p" "%p-%TY%Tm%Td"\n' | sh
--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org