omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Batch rename files

    Pythonista
    2
    2
    568
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wayland
      wayland last edited by

      I have a bunch of files I need to prepend with some text.

      Is this possible with Pythonista?

      Ie.

      Filename1 —> pre-text Filename1
      Filename2 —> pre-text Filename2
      Filename3 —> pre-text Filename3

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @wayland last edited by cvp

        @wayland tou may try this, as a script or as a command

        import os; [os.rename(f,'pre_text '+f) for f in os.listdir(path=os.path.expanduser('~/Documents/')) if f.startswith('Filename')]
        

        I'm sure that @ccc will do shorter

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors