Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

sed - removing/renaming file extensions.

  • 28-06-2005 4:57pm
    #1
    Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 93,596 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