AlexF777
asked on
looking for shell to rename all files like ?????.dlm.???????.????.pip into ?????.dlm.pip.???????.????
Thanks in advance,
-Al
-Al
I haven't tested this, so buyer beware.
$(ls ?????.dlm.???????.????.pip | awk '{
printf("mv %s %s%s%s\n",$0,substr($0,1,1 0),"pip",s ubstr($0,1 0,13))
}')
the awk statement should print out three space separated fields for each line of input.
Field 1 is the string "mv" (the rename command).
Field 2 is the original filename (the whole line).
Field 3 is made up of the first 10 characters of the input file name (?????.dlm.), the string "pip", then the string starting with the 10th character of the filename, 13 characters long (.???????.????).
The input to the awk command is a list of all files of the required format (?????.dlm.???????.????.pi p).
Finally, wrapping the whole lot in $(...) causes the shell (ksh or bash) to execute the output rather than just listing it to STDOUT.
Hope it works.
$(ls ?????.dlm.???????.????.pip
printf("mv %s %s%s%s\n",$0,substr($0,1,1
}')
the awk statement should print out three space separated fields for each line of input.
Field 1 is the string "mv" (the rename command).
Field 2 is the original filename (the whole line).
Field 3 is made up of the first 10 characters of the input file name (?????.dlm.), the string "pip", then the string starting with the 10th character of the filename, 13 characters long (.???????.????).
The input to the awk command is a list of all files of the required format (?????.dlm.???????.????.pi
Finally, wrapping the whole lot in $(...) causes the shell (ksh or bash) to execute the output rather than just listing it to STDOUT.
Hope it works.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do
mv $i ?????.dlm.pip.???????.????
done
i am assuming that instaed of ? u have some charecter there.