Hi
I have hundreds of files with the following format
I need to move this 1000 files from above to a different date
Is there a way to do that with a script or command
Hi
I have hundreds of files with the following format
I need to move this 1000 files from above to a different date
Is there a way to do that with a script or command
for FILE in *.01152015.csv
do
FILE2="${FILE/01152015/01212015}"
echo mv "$FILE" "$FILE2"
done
Remove the 'echo' once you've tested that it does what you want.
Thank you corona688 for nice approach, one more approach with find
command.
find -type f -name "*_01152015.csv" -exec bash -c 'echo mv $0 ${0/01152015/01212015}' {} \; 2>/dev/null
NOTE: We can remove echo
if happy with results, also if needed remove 2>/dev/null
which has been added to remove errors.
Thanks,
R. Singh
You should warn the OP that find is recursive, it will search inside subfolders.
Also, running an entire shell for each individual file you want to move is not an efficient solution. You only need one shell:
find -type f -name '*_01152015.csv' | while read FILE
do
FILE2="${FILE/01152015/01212015}"
echo mv "$FILE" "$FILE2"
done