Rename all files in the folder using the package

I would like to create a batch file to rename all files with the extension “.log” in the folder to be added with today's date.

For instance:

App.log will be added to App.log06112010 where the date is 06112010.

Please suggest

0
source share
2 answers
forfiles /m *.log /c "cmd /c ren @file @file06112010" 
+2
source
 #!/usr/bin/ksh export TODAYSDATE=`date "+%m%d%Y"` umask 000 for filename in $1 do if [ ! -f $1 ]; then echo "$filename doesn't exist!" else if [ -d $1 ]; then echo "Skipping directory $filename..." else mv $filename $filename$TODAYSDATE fi fi done 

Usage: move.sh "*.log"

0
source

Source: https://habr.com/ru/post/954173/


All Articles