Friday, April 3, 2015

Rename multiple files in folder with different pattern file name

I have 7000 folders and each folders have different pattern like this :




folder 1:



111070290_10_daftar_tabel.pdf
111070290_11_daftar_istilah.pdf
111070290_12_bab_1.pdf
111070290_13_bab_2.pdf
111070290_14_bab_3.pdf
111070290_15_bab_4.pdf
111070290_16_bab_5.pdf

111070290_17_daftar_pustaka.pdf
111070290_18_lampiran.pdf
111070290_1_cover.pdf
111070290_2_lembar_pernyataan_orisinalitas.pdf
111070290_3_lembar_pengesahan.pdf
111070290_4_abstrak.pdf
111070290_5_abstract.pdf
111070290_6_lembar_persembahan.pdf
111070290_7_kata_pengantar.pdf
111070290_8_daftar_isi.pdf

111070290_9_daftar_gambar.pdf


folder 2:



111070117_1_cover.pdf
111070117_2_lembar_pernyataan_orisinalitas.pdf
111070117_3_lembar_pengesahan.pdf
111070117_4_abstrak.pdf
111070117_5_abstract.pdf



There are a files i have to rename like example 111070117_3_pernyataan_orisinalitas.pdf to 111070117_disclaimer.pdf,etc.



But unfortunately file XXXXXXXXX_3_pernyataan_orisinalitas.pdf isn't always 3. Sometimes it can be 5 or 3 or anything else. I think it would be easier if all files names has the same number after the underline. So I think to catch my destiny should be done in 2 steps.




  1. rename 111070117_3_pernyataan_orisinalitas.pdf to 111070117_pernyataan_orisinalitas.pdf from all folders.

  2. rename 111070117_pernyataan_orisinalitas.pdf to 111070117_disclaimer.pdf.




Now i'm stuck in step 1, i need to remove a number after the underline. Any suggestion please?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...