0

I'm trying to remove some strings from filenames i have in a directory using bash. I've tried the following with no success.

rename --version

rename from util-linux 2.23.2

rename -v 's/[.].*//' *

rename -v 's/\.vesta-01:2,//' *

Original File Name(s):

1667874526.M308257P1693.vesta-01:2,

1667883117.M371701P32232.vesta-01:2,

Desired File Name(s):

1667874526

1667883117

2 Answers 2

2

rename from util-linux doesn't accept Perl substitution. See man 1 rename:

rename [options] expression replacement file...

You can use mv in a loop with parameter expansion instead:

for f in *.vesta-01:2, ; do
    mv "$f" "${f%%.*}"
done
Sign up to request clarification or add additional context in comments.

Comments

0

Try using mv with bash parameter expansion instead:

$ ls 166*
1667874526.M308257P1693.vesta-01:2  1667883117.M371701P32232.vesta-01:2
$ f1="1667874526.M308257P1693.vesta-01:2" ; mv "$f1" "${f1%%.*}"
$ f2="1667883117.M371701P32232.vesta-01:2" ; mv "$f2" "${f2%%.*}"
$ ls 166*
1667874526 1667883117

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.