Skip to content
Advertisement

Recursively replace linux file and folder names such as “%m-%d-%y.tar” with their actual creation month/day/year

I’m looking for something like this but with its original creation date instead of the current date.

Example: This folder (output below is from Linux command ls -ltr)

JavaScript

would have its file name changed to “04-26-20”.

Advertisement

Answer

Since there are some information missing I try to make assumptions and show a possible solution approach in general.

As already mentioned within the comments, for a filesystem like EXT3 there would be no creation time. It might be possible to use the modification time which could be gathered via the stat command, i.e.

JavaScript

… or even access time or change time.

The date of MTIME is given in format %Y-%m-%d and can be changed for the new file name via

JavaScript

Than it it is possible to rename the directory, i.e.

JavaScript

which will of course change the timestamps within the filesystem for the directory.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement