Tagged Questions

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

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
3k 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
948 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
17k 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
22k 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.
5
votes
1answer
1k 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 ...
9
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
295 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
325 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 ...
19
votes
6answers
15k 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
584 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

Recursive rename files and directories

I'm using below command for fname in *; do mv "$fname" $(echo "$fname" | sha1sum | cut -f1 -d' ') done ..but it only rename in current directory. Lets say I have many directories, and each ...
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
377 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
221 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
213 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
13k 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
304 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 ...
4
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
345 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
466 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 ...
18
votes
3answers
7k 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
385 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 ...
34
votes
6answers
61k 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
529 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
257 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
582 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
931 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 ...
7
votes
4answers
10k views

Copy/rename multiple files using regular expression (shell script)

I have a collection of files matching a pattern such as 'assignment02.cc', 'assignment02.h', 'assignment02.txt', etc. I would like to copy/rename these files into 'assignment03.cc', 'assignment03.h', ...
9
votes
3answers
5k views

How can I rename photos, given the EXIF data?

Let's say I have a bunch of photos, all with correct EXIF information, and the photos are randomly named (because of a problem I had). I have a little program called jhead which gives me the below ...
6
votes
5answers
1k views

How to clean up file extensions?

I have a directories with .MP3 files which I'd like to change the extensions to .mp3. What's the easiest way to do this? I'm think something along the lines of: find /RootPath -type f -iname "*.mp3" ...
17
votes
3answers
6k views

bulk rename (or correctly display) files with special characters

I have a bunch of directories and subdirectories that contain files with special characters, like this file: robbie@phil:~$ ls test�sktest.txt test?sktest.txt Find reveals an escape sequence: ...
4
votes
3answers
1k views

How to rename a file into a random GUID?

The task is to replace a file's (actually of all the files in a directory) name (but leave extension intact) with a random UUID/GUID. Any ideas on how to do this?
10
votes
3answers
1k views

Lowercasing all directories under a directory

I want to lowercase every directories' name under a directory. With which commands can I do that?
9
votes
7answers
5k views

How do you bulk move files up one directory safely?

How can I move files up a directory where there might be hundreds or thousands of files in the directory, and you might not be sure about whether there are dupes in ... What method would you use? How ...
2
votes
2answers
3k views

How do I correct a directory incorrectly copied into itself?

Given the following situation... <path>/mydir1/mydir2 ...where mydir2 should have overwritten mydir1, but was instead placed inside, and both directories actually have the same filename. How ...
9
votes
1answer
135 views

Strategies for maintaining a reference to a file after it was moved or renamed?

I've had a mac at work lately, and was amazed to see that Xcode would still find my latest project after I renamed its folder and moved it someplace else. Now I understand that this is the result of ...
8
votes
1answer
3k views

Command-line mv exclusion list

Is there a way to mv,cp, or any file operation such that I could specify all the files I don't want affected? For example, say I have a folder with the files file1, file2, and file3, and I want to ...
10
votes
3answers
9k views

How can I move files by type recursively from a directory and its sub-directories to another directory?

What would be a good way to move a file type from a directory and all of its sub-directories? Like "move all *.ogg in /thisdir recursively to /somedir". I tried a couple of things; my best effort was ...