Skip to main content
Copy edited (e.g. ref. <http://english.stackexchange.com/questions/2429/can-doubt-sometimes-mean-question>).
Source Link

rename Rename multiples files using bashBash scripting

I want to rename multiple files in the same directory using bashBash scripting. Names of the files are as follows:

file2602201409853.p
file0901201437404.p  
file0901201438761.p  
file1003201410069.p  
file2602201410180.p

I want to rename to the following format:

file2503201409853.p
file2503201437404.p  
file2503201438761.p  
file2503201410069.p  
file2503201410180.p

I was reading about the rename command, and try to do it this way, but it does nothing, I think I have doubts withquestions about the syntax. Then I read that you can make a loop using the mvmv command as follows:

for file in cmpsms*2014*.p; do
    mv "$file" "${file/cmpsms*2014*.p/cmpsms25032014*.p}"
done

But I can not rename the files, what. What am I doing wrong?

rename multiples files using bash scripting

I want to rename multiple files in the same directory using bash scripting. Names of the files are as follows:

file2602201409853.p
file0901201437404.p  
file0901201438761.p  
file1003201410069.p  
file2602201410180.p

I want to rename the following format:

file2503201409853.p
file2503201437404.p  
file2503201438761.p  
file2503201410069.p  
file2503201410180.p

I was reading about the rename command, and try to do it this way, but it does nothing, I think I have doubts with the syntax. Then I read that you can make a loop using the mv command as follows:

for file in cmpsms*2014*.p; do
    mv "$file" "${file/cmpsms*2014*.p/cmpsms25032014*.p}"
done

But I can not rename the files, what am I doing wrong?

Rename multiples files using Bash scripting

I want to rename multiple files in the same directory using Bash scripting. Names of the files are as follows:

file2602201409853.p
file0901201437404.p  
file0901201438761.p  
file1003201410069.p  
file2602201410180.p

I want to rename to the following format:

file2503201409853.p
file2503201437404.p  
file2503201438761.p  
file2503201410069.p  
file2503201410180.p

I was reading about the rename command, and try to do it this way, but it does nothing, I think I have questions about the syntax. Then I read that you can make a loop using the mv command as follows:

for file in cmpsms*2014*.p; do
    mv "$file" "${file/cmpsms*2014*.p/cmpsms25032014*.p}"
done

But I can not rename the files. What am I doing wrong?

edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
added 2 characters in body
Source Link
franvergara66
  • 1.1k
  • 3
  • 10
  • 10

I want to rename multiple files in the same directory using bash scripting. Names of the files are as follows:

file2602201409853.p
file0901201437404.p  
file0901201438761.p  
file1003201410069.p  
file2602201410180.p

I want to rename the following format:

file2503201409853.p
file2503201437404.p  
file2503201438761.p  
file2503201410069.p  
file2503201410180.p

I was reading about the rename command, and try to do it this way, but it does nothing, I think I have doubts with the syntax. Then I read that you can make a loop using the mv command as follows:

for file in cmpsms*2014*.p; do
    mv "$file" "${file/cmpsms*2014*.p/cmpsms25032014*.p}"
done

But I can not rename the files, what am I doing wrong?

I want to rename multiple files in the same directory using bash scripting. Names of the files are as follows:

file2602201409853.p
file0901201437404.p  
file0901201438761.p  
file1003201410069.p  
file2602201410180.p

I want to rename the following format:

file2503201409853.p
file2503201437404.p  
file2503201438761.p  
file2503201410069.p  
file2503201410180.p

I was reading about the rename command, and try to do it this way, but it does nothing, I think I have doubts with the syntax. Then I read that you can make a loop using the mv command as follows:

for file in cmpsms*2014*.p; do
    mv "$file" "${file/cmpsms*2014*/cmpsms25032014*.p}"
done

But I can not rename the files, what am I doing wrong?

I want to rename multiple files in the same directory using bash scripting. Names of the files are as follows:

file2602201409853.p
file0901201437404.p  
file0901201438761.p  
file1003201410069.p  
file2602201410180.p

I want to rename the following format:

file2503201409853.p
file2503201437404.p  
file2503201438761.p  
file2503201410069.p  
file2503201410180.p

I was reading about the rename command, and try to do it this way, but it does nothing, I think I have doubts with the syntax. Then I read that you can make a loop using the mv command as follows:

for file in cmpsms*2014*.p; do
    mv "$file" "${file/cmpsms*2014*.p/cmpsms25032014*.p}"
done

But I can not rename the files, what am I doing wrong?

edited tags
Link
Kiwy
  • 9.9k
  • 13
  • 51
  • 81
Loading
Source Link
franvergara66
  • 1.1k
  • 3
  • 10
  • 10
Loading