Reputation: 443
I'm trying to create a bash script that will run on a folder and check the last modified stamp for each file in that folder then append that date to each file in the folder as it goes through them. For example:
IMG1_movie.mov
becomes
IMG1_movie_02032015.mov
There are a few examples online but the ones I've found don't cover the last modified date only appending the current date and none have batch capabilities. Any guidance is appreciated thanks.
Upvotes: 0
Views: 525
Reputation: 2717
You could write that part of the code as
new_filename="$(date -r $filename +%Y%m%d)"
where the date
command arguments does the formatting for you. I made the format as YYYYMMDD
. You could change the arguments to the order in which you want the date to appear.
Upvotes: 1