Tag Info

New answers tagged

1

It's not as efficient, but the code is easier to read and understand, in my opinion, if you just copy the files and then delete after. find /original/file/path/* -type f -mtime +7 -exec cp {} /new/file/path/ \; find /original/file/path/* -type f -mtime +7 -exec rm -rf {} \;


0

qmv The command qmv from renameutils opens an editor showing a list of filenames with two colums, separated by a tab. Each row shows one of the filenames, the same in both columns. The right column is representing the new names of the files. To make changes, edit the names on the right side. In this example, :%s/... or visual block mode are helpful. ...


1

POSIX: for f in *;do x=${f#pairs};y=${f#*_};mv $f pairs_$(printf %02d_%02d ${x%_*} ${y%.mp3}).mp3;done zsh: autoload zmv;zmv 'pairs(*)_(*).mp3' 'pairs${(l:2::0:)1}_${(l:2::0:)2}.mp3'


1

Most systems include a tool called dos2unix which you can "gin up" in a script to process the files that you need to perform this operation on. If the files are all in a directory you can use find to locate them and then operate on each one individually like so: $ find . -type f -exec dos2unix {} + Example Say I had this directory structure $ tree . ...


0

Here's how I change all the file extensions in the current directory on Debian. rename "s/oldExtension/newExtension/" *.txt


0

As far as the matching is concerned, you'd need to be quite careful in order to build anything robust. For example, assuming that the first and middle names must start with a letter may contain hyphens (but no other punctuation or whitespace) your given-name pattern becomes something like [[:alpha:]][[:alpha:]-]*. You can then make an optional ...


1

Since the description part of the filename can contain the pattern - (a hyphen between two spaces), you can change that to some symbol that doesn't occur in the description part. I chose £, but that's purely arbitrary. rename 's/ - /£/' * rename 's/([^,]*), ([^£]*)£/$2 $1 - /' * s/ - /£/' tells rename to replace the first instance of - it finds with£. The ...


0

BIngo! for i in VTS_01_[1-4]*B;do echo mv $i "$(echo $i|sed 's/VTS/Movie/g;s/VOB/avi/g')";done Is more useful with commands like mencoder,etc


3

You can do it in two steps e.g. first remove the extension, then substitute the VTS_01 prefix: $ for i in VTS_01_[1-4]*B; do b="${i%.VOB}"; echo "${b/VTS_01/Movie}.avi"; done Movie_1.avi Movie_2.avi Movie_3.avi


1

Why don't you use python? Something like $ ipython In [1]: import os In [2]: all_files = os.listdir(".") In [3]: for filename in all_files: In [4]: newname = 'Movie' + filename[6:9] + 'avi' In [5]: os.rename(filename, newname) should solve your problem.


2

Use rename program. It uses perl expression. How ever here we have no complex expression. In this case you can use this: rename VTS_01 movie VTS_01*VOB


1

With the Perl rename command: rename 's/([0-9]+)_([0-9]+)/sprintf("%02d_%02d",$1,$2)/e' *.mp3 The e modifier to the s substitution operator means that the replacement is a Perl expression rather than an interpolated string. The format %02d for the function sprintf formats an integer with exactly two digits, adding leading zeroes as necessary. ...


0

I ended up using a multi-step process with the rename command. It could probably be simplified: rename 's/(pairs)([0-9])_/$1Z$2_/' *.mp3 rename 's/(_)([0-9])\./$1Z$2\./' *.mp3 rename 's/Z/0/' *.mp3 rename 's/Z/0/' *.mp3 (The $1 and $2 refer to the parentheses in the first part) ("Z" is just a place holder because "0" gets mixed up with "$1") idea from ...



Top 50 recent answers are included