Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

sed - removing/renaming file extensions.

  • 28-06-2005 04:57PM
    #1
    Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 96,352 Mod ✭✭✭✭


    I want to copy files into a folder, but if a file of the name already exists I want to rename one of them so I get Filename_X.EXT where X is the next number.

    I can remove file extensions by
    dir | sed s\...$\\ but I need to use the extension later on too.

    Should I be able to use sed h.....$ to store the extension and then append it later ?


    I could use sed to reverse the string, then use FOR (Windows command line) to remove everything up to the first dot and then use sed to reverse the three characters, but that would just be stupid if there is an easier way.

    I could also just process one file type at a time, but would rather a generic way.

    sed scripts I've looked at
    http://sed.sourceforge.net/sed1line.txt
    http://www.student.northpark.edu/pemente/sed/sedfaq.html


Advertisement