Follow

Just asking here in case anyone, withj decent bash expertise can help please.

Having copied files from an old PVR (digitial video recorder thingy) we have files such as this

New:.1864-2015-May-30.20:02:17.307534.nts
New:.1864-2015-May-30.20:02:17.307534.ts
New:.1864-2015-May-30.21:00:30.091333.hmt
New:.1864-2015-May-30.21:00:30.091333.nts
New:.1864-2015-May-30.21:00:30.091333.ts

These are on my main computer hard disk, I have a 2nd that is currently FAT32 (I think) but I can't copy these files due to the characters in the filename.

Is there a easy way to take these files, and rename them so I can stripo out all but the final period (which is between '091333.ts' for example.

I am running Debian, and it wom't let me copy over to the other HDD, While I can do this manually there are LOTS of files. So there has to be a way to do this, perhaps a combination of

rename , sed or other commands.

Any pointers welcome please.

Thanks

Paul

,,,,

@zleap

If you are okay with #KDE apps, #KRename is great for this sort of thing.

You could also try rename (the perl version - it is "perl-rename" on #gentoo. Something like

# perl-rename 's/:/-/g' *

and

# perl-rename 's/\./_/g' *

BUT, not sure if you need to escape the . or not in that second one.

If you use #emacs, #dired would also let you do find and replace to bulk rename. Open a dired buffer in the folder, ctrl-x ctrl-q to make the buffer editable. C-c C-c to finish and rename.

@zleap You have gotten several helpful answers already, but let me just plug ‘wdired’, in case you are familiar with emacs and emacs keyboard macros. This command lets you edit a directory as you would a file and have all changes applied to the filesystem.

@mapcar

I tried one of the cli methods earlier and that worked, also took a look at thnar and this has some really nice rename features.

As there is no rush for this, I am going to use this as an opportuniy to

a) learn some more command line tools
b) make a few vokoscreen videocasts of various tools in action as it is a good learning and teaching opportunity.

Paul

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.