fork download
  1. #!/bin/bash
  2. # your code goes here
  3. while read f; do
  4. # strips everything after the first / so this is our foldername
  5. foldername=${f/\/*/}
  6. # creates the new filename from substrings of the
  7. # original filename concatenated to the foldername
  8. newfilename=".${f:1:3}${foldername}_${f:4}"
  9. # if you are satisfied with the output, just leave out the `echo`
  10. # from below
  11. echo mv ${f} ${newfilename}
  12. done
Success #stdin #stdout 0.03s 5312KB
stdin
A/C_17x17.p
A/C_32x32.p
A/C.p
B/C_12x12.p
B/C_4x4.p
B/C_A_3x3.p
B/C_X_91x91.p
G/C_6x6.p
G/C_7x7.p
G/C_A_113x113.p
G/C_A_8x8.p
G/C_B.p
stdout
mv A/C_17x17.p ./C_A_17x17.p
mv A/C_32x32.p ./C_A_32x32.p
mv A/C.p ./C.A_p
mv B/C_12x12.p ./C_B_12x12.p
mv B/C_4x4.p ./C_B_4x4.p
mv B/C_A_3x3.p ./C_B_A_3x3.p
mv B/C_X_91x91.p ./C_B_X_91x91.p
mv G/C_6x6.p ./C_G_6x6.p
mv G/C_7x7.p ./C_G_7x7.p
mv G/C_A_113x113.p ./C_G_A_113x113.p
mv G/C_A_8x8.p ./C_G_A_8x8.p