Python Forum
how to increment all file names in a folder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to increment all file names in a folder
#6
so you need to make a mass rename. yeah that obviously needs a loop. you could write a script to do it. you could do it in Python, but in a shell script might be easier if you know shell scripting. you could do it in Python as a learning exercise. me, personally, i'd do it in a command (in bash) in that directory like:

(ls -1|while read f;do mv $f ${f}1;done)

if you want the "1" to be before the "." it will be a slightly longer command. but maybe it is better for you to do this as a Python script. write something that outputs the commands to do it and when it makes all the right commands then pipe them into a shell.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
RE: how to increment all file names in a folder - by Skaperen - Sep-10-2018, 07:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 524 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Reading a file name fron a folder on my desktop Fiona 4 894 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  help to increment a third list hermine 7 1,323 Nov-29-2022, 04:19 PM
Last Post: perfringo
  rename same file names in different directories elnk 0 707 Nov-04-2022, 05:23 PM
Last Post: elnk
  mysql id auto increment not working tantony 10 2,404 Oct-18-2022, 11:43 PM
Last Post: Pedroski55
  Function not executing each file in folder mathew_31 9 2,233 Aug-22-2022, 08:40 PM
Last Post: deanhystad
  Dynamic File Name to a shared folder with open command in python sjcsvatt 9 6,014 Jan-07-2022, 04:55 PM
Last Post: bowlofred
  Code to check folder and sub folders for new file and alert fioranosnake 2 1,929 Jan-06-2022, 05:03 PM
Last Post: deanhystad
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,469 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  How to import file and function in another folder SriRajesh 1 3,145 Dec-18-2021, 08:35 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020