Skip to main content

On linux, this works:

D=`stattimestamp=$(stat -c %y foldername`foldername)
mv foldername new_foldername
touch -d "$D""$timestamp" new_foldername

This is usually faster. Explanation:The stat -c %y givescommand returns the modification date of the folder, in readable form. That value is retained and used with the command touch -d "$D""$timestamp" to set the time of the new folder.

On linux, this works:

D=`stat -c %y foldername`
mv foldername new_foldername
touch -d "$D" new_foldername

This is usually faster. Explanation: stat -c %y gives the modification date of the folder, in readable form. That value is retained and used with the command touch -d "$D" to set the time of the new folder.

On linux, this works:

timestamp=$(stat -c %y foldername)
mv foldername new_foldername
touch -d "$timestamp" new_foldername

The stat -c %y command returns the modification date of the folder, in readable form. That value is retained and used with the command touch -d "$timestamp" to set the time of the new folder.

Source Link
klen
  • 41
  • 2

On linux, this works:

D=`stat -c %y foldername`
mv foldername new_foldername
touch -d "$D" new_foldername

This is usually faster. Explanation: stat -c %y gives the modification date of the folder, in readable form. That value is retained and used with the command touch -d "$D" to set the time of the new folder.