I need to change the timestamp of about 5000 files.
Typing touch file1.txt, touch file2.txt will take me forever.
Is there a way to do something in the lines of touch -R *?
I need to change the timestamp of about 5000 files.
Typing touch file1.txt, touch file2.txt will take me forever.
Is there a way to do something in the lines of touch -R *?
touch **/**
This updates the timestamps of all files and directories recursively within the current directory when using Zsh or bash -O globstar.
g_p's answer makes the timestamp "now" but if for instance you forgot the cp -p parameter and need to replace timestamps with their originals recursively without recopying all the files. Here is what worked for me:
find /Destination -exec bash -c 'touch -r "${0/Destination/Source}" "$0"' {} \;
This assumes a duplicate file/ folder tree of Source: /Source and Destination: /Destination
find searches the Destination for all files & dirs (which need timestamps) and -exec ... {} runs a command for each result.bash -c ' ... ' executes a shell command using bash.$0 holds the find result.touch -r {timestamped_file} {file_to_stamp} uses a bash replace command ${string/search/replace} to set timestamp source appropriately.