0

I am using Mac Terminal and I need to delete end of filename.

Example of filename : 1516092009.M432844P7000.camel5,S=14022,W=14295/2,

I need to delete the end /2, and I tried command:

rename 's/\/2,//g' * which I think should work but don't. Not all of files in folder have this end.

Any ideas? Thank you

10
  • 2
    This is not a valid filename. 1516092009.M432844P7000.camel5,S=14022,W=14295 is a directory and 2, is the file. Commented Aug 12, 2020 at 13:11
  • 1
    it's not possible to have a filename with / in it. Commented Aug 12, 2020 at 13:30
  • 2
    Please show partial output of ls -alp for some of these files. Commented Aug 12, 2020 at 13:37
  • 3
    If you see a file ending /2, in the Finder browser, it will end in :2, when viewed in Terminal. cf apple.stackexchange.com/questions/173529/…. If you want to rename in the command line, you'll need to use the filename as visible in shell. Commented Aug 12, 2020 at 13:38
  • 1
    @DominikNovák Please show what the filenames are when viewed in the terminal, e.g. by updating the question and adding the output of ls -d for one of the files. Jesse is totally correct in saying that a filename can't contain a / character, not on any Unix system. If you see a / in a filename, then that is the result of decoding some other combination of characters in a particular application, as user4556274 suggests. Commented Aug 12, 2020 at 16:39

1 Answer 1

0

Why don't you list the file in the Finder and just delete the last 2 characters from there. You can select the filename and then change the name.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.