The rename tag refers to the action of giving a different name to either an existing file or to a copy of a file as part of some other operations (.e.g. remote copy, backup). Use this tag as well for questions related to the (perl) rename command.

learn more… | top users | synonyms

5
votes
1answer
4k views

mv file without write permission to the source file

I just realised that I can move a file that I do not own and don't have write permissions on. I have write permissions to the directory, so I am guessing that is why I could move it, but in this ...
1
vote
3answers
2k views

rename multiple files with rename command? [duplicate]

Possible Duplicate: How can I rename a lot of files using a regex? Rename All Files with a Certain Name There are files with ORDER_EVENTS_SOMETHING_20120117.log ...
4
votes
2answers
289 views

Can I move a directory with open files?

Imagine a bunch of processes using a /home/user/logs directory. They have some logs open for a longer time.
2
votes
3answers
6k views

Batch renaming files with pattern

I have some files named like these: 63018933.mp4?token=1325697436_b0c3e70c6e339380b4a484c576a8c287 63808488.mp4?token=1325697401_4ae5f7a68d93873c8881b303e7655e14 How do I rename all them to, for ...
8
votes
3answers
3k views

How can I use ms-dos style wildcards with ls and mv?

I have the misfortune of coming from a MS-DOS background - but at least it makes me appreciate how much more powerful Linux is. I've been working on getting my Linux-Fu up to par, but there are a ...
4
votes
2answers
849 views

mv on a glob pattern does not work without sudo

I am using MySQL database on Ubuntu machine. My MySQL data directory is /var/lib/mysql/ , since I have a database named "db_test" , so, I have a directory named db_test/ under /var/lib/mysql/ . And ...
3
votes
2answers
650 views

Simple shell script needed to move database files

I am using MySQL on Ubuntu machine. I need to physically move around the database files under /var/lib/mysql/ (this is where all the databases directories are located). Say I have two databases, ...
3
votes
1answer
2k views

Rename All Files with a Certain Name

I'm trying to find certain files with the name "stringx" and replace the name (but not the extension) with "stringy". So basically for stringx.txt and stingx.cs, I'd want stringy.txt and stringy.cs. ...
6
votes
2answers
4k views

How can I rename a lot of files using a regex?

I want to rename a lot of files on Mac OS X (10.7.2).. I don't have the perl package for the rename command. My files have names like "T452-102456-0.png" and I want to delete the "-0" part. I know I ...
3
votes
2answers
832 views

Move with possible rename

Is it possible to construct a command that will move the file to another directory and if the same file is already there, generate some random string that is not in the name of some file in the ...
4
votes
2answers
10k views

How can I move a directory onto an existing directory?

I need to essentially merge changes on two trees, applying the changes from branch 2 to branch 1. I have trees like this: media ├── cd │   ├── 0 │   │   ├── file1 │   │   ├── file2 │   │   └── file3 ...
9
votes
1answer
3k views

Why can't I have a folder and a file with the same name?

I've never had this problem before, but for some reason, I can't rename my folder to packages/. This is the structure: root - packages_old/ - packages When I try to rename the folder with ...
1
vote
3answers
4k views

Rename Multiple files and add date before the files

I have a folder contains one or more tar.gz files. I want to add current date before each files when the script run. For example: Two file name(those files will be created each day, but the name ...
4
votes
5answers
2k views

Padding a number in a filename to a fixed length

I have a directory of files such as: file.1.png file.2.png … file.10.png … file.1000.png file.1001.png … How can I pad the number to 4 digits? It should end up like this: file.0001.png ...
5
votes
1answer
997 views

Renaming files to have lower case extensions with 'rename'

I'm trying to currently rename a large set of files and have been using quite kludgy methods to do so, such as: rename 's:(.*)\.MOV:$1.mov:g' *.MOV rename 's:(.*)\.JPG:$1.jpg:g' *.JPG What I'd ...
4
votes
6answers
19k views

Changing extension to multiple files

I would like to change file extension from *.txt file to *.text file, tried using the basename command, but I am having trouble on changing more than 1 file, I am getting a basename: too many ...
13
votes
5answers
24k views

Move folder content up one level

I have a directory that is unpacked, but is in a folder. How can I move the contents up one level? I am accessing CentOS via SSH.
6
votes
1answer
2k views

zmv for zsh: Dry runs and man pages

I've heard great things about zmv in zsh, and would love to really learn to use it. However, I am still relatively unexperienced in zsh, and have some basic questions: Is there is a man page for zmv ...
10
votes
2answers
2k views

mv a file without breaking a symlink to that file

Is it possible to mv a file w/out breaking a symbolic link to that file? My initial response to this is no, and I'm working out a script based solution to change the links immediately following the ...
5
votes
2answers
304 views

mv filename .. (Where will the file go?)

[root@localhost /home/chankey/Desktop/Downloads]# ls myproject.plx [root@localhost /home/chankey/Desktop/Downloads]# mv myproject.plx .. I had the file in Downloads folder. I used mv command as ...
3
votes
2answers
332 views

Organizing messy folder based on filetype

I have music lying on my desktop and in my downloads and Music folders. Similarly, I have .odt files lying all over my home folder (mainly desktop). Is there a tool (preferably GUI so my parents can ...
20
votes
6answers
17k views

How to replace one char with another in all filenames of the current directories?

How do you rename all files/subdirs in the current folder? Lets say, I have many files and subdirs that are with spaces and I want to replace all the spaces with an underscore. File 1 File 2 File 3 ...
2
votes
3answers
592 views

Rename files with random characters from sha1sum. Does it unique?

I'm using this command to rename files with random characters from sha1sum and move all files from subdirectories to current directory: for fname in `find . -type f`; do mv "$fname" $(echo "$fname" | ...
5
votes
5answers
4k views

Recursively rename files and directories

I'm using this command to rename files: for fname in *; do mv "$fname" $(echo "$fname" | sha1sum | cut -f1 -d' ') done But it only renames in the current directory. Let's say I have many ...
3
votes
4answers
2k views

rename character “â” of directory name?

I'm trying to rename rename character â of directory name to be blank. For example, directory with name how-â8093-to. This is the command I use, including some other modification find . -type d | ...
4
votes
3answers
3k views

How do I move some but not all files from one directory to another?

I need to move my files from one directory to other. But there is some issues. My file name pattern is like: apple.0, apple.<n>, n -> {0,1,2,3 ...~ } so mv apple.* will not work, because ...
3
votes
2answers
386 views

Splitting a large directory tree by file type

I have a large data directory (20-30Gb) on my Ubuntu 10.10 desktop machine that consists of many raw data files, processed data files, and assorted scripts, tables, figures etc. generated from the ...
2
votes
1answer
223 views

Rename beginning of file name using specific text in the file itself

I have many files in directory (file1.txt, file2.txt, ...) Every files contains bunch of lines. One of the line is specific text thetext followed by random number just like thetext56, thetext21, etc. ...
2
votes
2answers
217 views

Move one file at a time based from specific number in the files

Based from this question, The HTML files date format has been changed. All of the HTML files have the date such like below: 20110730dateishere dateishere is intentionally added by me in the files, ...
2
votes
3answers
1k views

sorting filenames numerically when they have non-numeric prefix

I have files in the following format: x1 x2 ... x10 x11 ... x101 ... I want to rename these files, so they all have the same name length: x001 x002 ... x010 ... I can do this with files, that don't ...
4
votes
3answers
14k views

Copy files with renaming

I have a huge file tree. Some files have same name but in different case, e.g. 'some_code.c' and 'Some_Code.c'. So when I'm trying to copy it to NTFS/FAT filesystem it asks me about whether i'm ...
5
votes
2answers
185 views

How does bash continue to work correctly when you move its working directory?

On Linux, I moved a directory to another directory using mv, and in another shell, my working directory happened to be the directory that was moved. I ran hg pull in that shell, and to my surprise, ...
2
votes
2answers
311 views

How to update a content management installation by overwriting existing files via ssh and shell?

I have installed a cms (modx) on a webserver running CentOS 5 and Apache 2.2. Now there is a new version and I would like to update it. The instructions in the modx-wiki suggest to overwrite the ...
5
votes
1answer
1k views

How to pipe the result of 'date' command to 'mv' command

I want to rename my file to the current timestamp.I know how to get the current timestamp("date +%s") but how can I pipe it to 'mv' command?
0
votes
0answers
41 views

How to change ALL the postfixes of files in a single directory, single command [duplicate]

Possible Duplicate: How to clean up file extensions? have a directory full of files ending with .JPG I need to change them all to .jpg How?
6
votes
3answers
363 views

“mkdir foo; svn mv * foo”

I often want to do some variant of this idiom: $ mkdir 2010 $ svn mv * 2010 Of course, I get an error because the glob matches 2010 as well: svn: Cannot copy path '2010' into its own child ...
0
votes
0answers
360 views

ranaming multiple file in unix [duplicate]

Possible Duplicate: Renaming multiple files in unix Rename all files within a folder with the first word of their content(remember all the files should be text files. For example if a.txt ...
3
votes
6answers
4k views

Renaming multiple files based on their contents

How can I rename all files within a folder with the first word of their content? For example if a.txt contains “Unix is an OS” in its first line then a.txt should be renamed to Unix.txt
3
votes
5answers
4k views

Rename all the files within a folder with prefix “Unix_”

Rename all the files within a folder with prefix “Unix_” i.e. suppose a folder has two files a.txt and b.pdf than they both should be renamed from a single command to Unix_a.txt and Unix_b.pdf
4
votes
1answer
2k views

Batch copy and rename with regexp

I am wondering whether there is a way how to copy and rename a bunch of files without scripting. I have files with names like prefix_12345678901_12345678901_suffix.ext and I need to copy all of them ...
2
votes
3answers
497 views

Batch File Rename Using Mapping File

I have a large collection of image files, for example: a.png, b.png, c.png, etc If I have a file with mappings of filenames to numbers, like so (ignore the format, it could be anything): a=>1 ...
7
votes
5answers
16k views

How copy and rename files found in “find” function Linux?

I have a folder named /home/user/temps which has 487 folders. In each folder I have a file called thumb.png. I want to copy all files named thumb.png to a separate folder and rename them based on ...
20
votes
3answers
8k views

How to choose directory name during untarring

Say I have file named ugly_name.tar, which when extracted, becomes ugly_name directory. What command can I use such that the resulting directory name is pretty_name instead?
3
votes
1answer
403 views

Multiple renaming files [duplicate]

Possible Duplicate: How to clean up file extensions? I'd like to rename files with extension .flac.mp3 to extension .mp3. I used the following command $ for i in *; do mv $i `echo $i | sed ...
35
votes
6answers
66k views

How to overwrite target files with mv?

I have a ton of files and dirs in a subdirectory I want to move to the parent directory. There are already some files and dirs in the target directory which need to be overwritten. Files that are only ...
2
votes
3answers
533 views

Selective recursive move?

Is there a command like mv --preserve-structure src src/1 src/2/3 dst which creates dst/1 and dst/2/3? It should work similar to mv src/* dst, but move only the subtrees listed.
2
votes
1answer
268 views

Restoring backup files

I have a directory in which are listed some .py files and some .py.bak files. I want to delete the .py files and restore the backup file renaming them *.py. Is there a shell script that can do this? ...
2
votes
2answers
603 views

mv failed halfway through - is source directory intact

I ran mv a-folder /home/me on a machine and half way through the move the destination device filled up. a-folder was made up of folders and files in various subdirectories. Does mv leave the source ...
14
votes
2answers
3k views

How do open files behave on linux systems?

I just renamed a log file to "foo.log.old", and assumed that the application will start writing a new logfile at "foo.log". I was surprised to discover that it tracked the logfile to its new name, and ...
1
vote
4answers
949 views

rename directory of images numeric

I'm trying to rename a directory full of images like so: test.jpg funny.gif sad.png filename.PNG filenaaskjas.JPG to: 1.jpg 2.gif 3.png 4.png 5.jpg I've got it working ...