Rename Files Recursively Without Updating Date?


Zudnic

Recommended Posts

Hi, I have a bunch of videos that I want to upload to Google Photos. They need to have their extensions changed, but I want to preserve the date/time of the files so they are indexed properly.

 

Is there a single command that I can run that will:

  • Recursively go through a directory and subdirectories and rename any file ending in '.foo' with '.bar'
  • Do NOT update the file date/time

 

I've done some research on this online and it appears there are several approaches to do one or the other, but I cannot determine the best way to combine the two. I am also a little gun-shy as a n00b and I really only have one shot at this, if I screw up the dates/times they're not recoverable.

 

Thanks in advance!

Link to comment

You would probably need to 'copy' the source file to the destination using the --preserve=all option followed by deleting the source file (move [mv] doesn't allow to preserve timestamps).

 

i.e.

cp --preserve=all [source] [destination]

rm [source]

 

I'm not big on making scripts so perhaps someone else can help with that, or you can attempt it yourself.  Might want to not remove anything until you are sure it works, or create a dummy directory and files to test on.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.