4
votes
2answers
52 views

How to exchange words in a filename using the shell?

One of my customers is a school. On their file server all projects have a directory with the same naming scheme. <last name>, <first name> <second name>? - <project ...
1
vote
2answers
113 views

Rename a file dynamically containing spaces [duplicate]

I want to rename a file dynamically based on data which contains spaces Name="Abc DEF" Name1="GHI JKL" mv /sample/pdf/noriginalName.pdf /sample/outputPdf/${NAME}${Name1}".pdf" But it gives me an ...
4
votes
4answers
84 views

Renaming multiple files with rename

I need help renaming files in batch--the other questions I browsed don't exactly address my problem. The names of my files are generated non-deterministically, so I can't predict what they will be ...
5
votes
3answers
295 views

How to remove dot and space from beginning of filenames

I'm trying to change jpg files named with a dot and a space at the beginning and with a missing dot before the end (like this . Startjpg to Start.jpg The dot makes the files hidden from sed and ls ...
2
votes
1answer
73 views

Renaming the files and move to other path

I need to rename the files given below and move to some other path 1234551abcde20140718023216001.txt.809047512.2014_07_07_13:47:44 000001abcde20140718023216001.txt.34568.001.2014_07_07_13:50:44 ...
3
votes
1answer
299 views

Rename files with spaces in a BusyBox shell

I'm trying to rename some files on my Synology Diskstation via SSH. The available shell is the BusyBox built-in shell: BusyBox v1.16.1 (2013-04-16 20:13:10 CST) built-in shell (ash) The move ...
1
vote
4answers
463 views

renaming multiple files increment order

I have the following files SSt12.precip.374.sub.climatology.ctl SSt12.precip.2874.sub.climatology.ctl SSt12.precip.3764.sub.climatology.ctl SSt12.precip.6774.sub.climatology.ctl I want to rename ...
1
vote
2answers
81 views

Renaming a whole folder content

I'm on OSX 10.9.2 (BASH 3.5) and I wanted to rename a whole folder content names. So I run a script and somehow ended with this: s01eDavid.Letterman.2014.02.27.Stupid.Human.Tricks.x264-SWOLLED.mp4 ...
1
vote
1answer
67 views

How do I rename lots of files on a directory without changing their extensions? [duplicate]

I have a problem! I have a bunch of image files with extensions. Jpg and. Png. I wrote a script that renames the files, changing their names in a pattern followed by a number like this: ... ...
3
votes
3answers
441 views

Shell Script to move folders containing a specific word

I'm searching for an simple shell script to mv all folders in /var/www/uploads/ that containing Math or Physics in the name to /mnt/Backup/. I've never done something like that before, due to the ...
3
votes
4answers
497 views

how to rename files while copying?

How would I copy (archive style where date isn't changed) all the files in a backup directory to the user's directory while renaming each file to remove the random string portion from the name (i.e., ...
3
votes
7answers
492 views

Batch renaming of files [duplicate]

I have a directory full of images: DSCN4749.JPG DSCN4750.JPG DSCN4892.JPG ... And I would like a one-liner to rename them to (say). dscn4749.jpg dscn4750.jpg dscn4892.jpg ... How do I do this? ...
4
votes
4answers
2k views

What is the most efficient way to move a large number of files that reside in a single directory?

CentOS 5.x I apologize if this is a repeat question. I've seen a lot of similar questions (regarding deleting files) but not exactly the same scenario. I have a directory containing hundreds of ...
3
votes
2answers
39 views

Overriding amended time stamps

I need to make it so the files in current directory get amended with a timestamp. It works fine for the first time, but once I run it again it adds another timestamp to the file. I need a way to ...
3
votes
3answers
418 views

Rename multiple files, sub directories, and insert characters at specific location on OSX

I have files and directories starting with "cateory-icon-" in many sub directories. I am trying to rename them recursively to "category-icons-". Please note that I added missing "g" to the category ...
3
votes
2answers
622 views

How to copy multiple files but keep their extensions the same?

I am looping through a number of files, and $file represents the current file. How can I make copies or renames and keep the extension the same for this current file? e.g. if $file = x.jpg How to ...
6
votes
3answers
4k views

Rename files in the local folder adding a prefix or suffix

I have many files in a folder and I want to add either prefix or a suffix (not both) to them. I checked here and found out I can use for filename in *.jpg; do mv "$filename" "prefix_$filename"; done; ...
6
votes
4answers
2k views

Bash script to rename files from a text file source

I'm fairly new to bash; I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as ...
3
votes
1answer
2k views

Using regex in ls and mv

I have a directory structure like this ├── UK │   ├── BuyBand_go_UK.png │   ├── BuyBand_go_UK.svg │   ├── BuyBand_K.png │   ├── BuyBand_K.svg │   ├── BuyBago_UK.png │   ├── BuyBago_UK.svg │   ├── ...
1
vote
3answers
62 views

Rename directory from within directory?

How would I rename a directory from within that directory? For example: ~/tmp $ rn tmp2 ~/tmp2 $ I can do that with: cd .. && mv tmp tmp2 && cd tmp2, but not sure how to make it ...
1
vote
1answer
289 views

Trouble with mv and adding the date

I want to be able to move $oldfile to my backup folder and add the date to the file name. So I tried this... mv $oldfile /home/u0146121/backupfiles/$oldfile_$(date +%F-%T) This just gives me this ...
3
votes
2answers
9k views

mv: cannot stat No such file or directory in shell script

I wrote a script to move some files form one folder to another folder but I got the following error, I checked 2 folders and notice for 1 folder there are such files and another there is no such ...
3
votes
3answers
3k views

How to move all files with a certain file extension from subdirectories to a single directory

I have a directory that contains many subdirectories. The subdirectories contain lots of types of files with different file extensions. I want to move (not copy) all the files of one type into a new ...
1
vote
3answers
546 views

Why is this Bash command using regex not replacing my brackets?

I have this command to go through all my files in my Music directory, and all subdirectories, and replace any square brackets in the file name with rounded brackets: find /home/Music/ -depth -name "* ...
1
vote
2answers
172 views

How to strip directory structure with command line (or script)

I have a large collection of files packed into a two-level directory structure with many, many, many folders. In other words, I have a folder with a great many subfolders in it. There are no ...
4
votes
3answers
2k views

Backup file with .bak _before_ filename extension

I commonly backup config files on servers without version control like so: # cp httpd.conf{,.bak} # ls httpd.conf httpd.conf.bak However, for files in the web root I take the time to carefully ...
1
vote
2answers
203 views

How to move files from one directory to a nested directory using SSH?

I'm new to SSH. I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.
1
vote
4answers
1k views

How to rename files with sed and csv

I'm new with Linux, sed, and awk but I don't mind challenging myself on new ideas. That being said, I understand the purpose and how to use rename and sed for a common event such as adding a $date or ...
0
votes
4answers
558 views

Bash Globbing Variable Substitution? [duplicate]

Possible Duplicate: Batch renaming files I want to rename files using their existing name as a base for the new one. So if I can ls these files with ls blue*+(.png) I'd want to rename ...
0
votes
1answer
76 views

Find and use the path of a file?

I'm trying to find the path of a file and move it. When I try realpath, it is not useful. For example : I want to move the file All Hail the Generalist - Vikram Mansharamani - Harvard Business ...
-1
votes
1answer
227 views

How to add a string of numbers to multiple text files in a directory?

file.txt file2.txt file3.txt I want to add 99999 to the begining of the all the file names without changing anything else in the file name in solaris 10.
1
vote
3answers
124 views

Restructuring directories into a hierarchy

I have the following type of folder structure containing thousands of folders. The folder names are as such with different names etc .test .test.subfolder .test.subfolder.subsubfolder .folder ...
4
votes
4answers
249 views

Follow a moved file to its destination directory

Is there a way to move a file from a directory to another and then cd into the latter in one command? Something like mv /a/file /another/dir && cd _ but without typing second time the ...
4
votes
1answer
243 views

xterm doesn't switch directory when it is moved

Recently I was very frustrated with xterm not behaving as expected. This is what I was doing: open xterm run the following commands: $ mkdir test_01 $ cd test_01/ $ echo 'a' > a $ cat a The ...
1
vote
1answer
426 views

rename files maching specific mtime value within directory

I use simple set of shell commands to in order to create mysqldumps daily. The script is called by cron daemon. It looks like: presentdate="`date +%d-%m-%Y_%H:%M.%S`" basedir="/var/db_my_backup" ...
13
votes
5answers
888 views

How to remove the (1) from filenames using the find command

I recently converted all of my FLAC files to a lower sampling rate of 44.1 kHz and bit depth of 24 bits (because iPhone/iPod don't support anything above that) using XLD on my Mac OS 10.7 (Lion). ...
3
votes
3answers
2k views

Removing apostrophe from all file names

I tried to remove apostrophe from all files' names in the directory. for i in *; do mv $i `echo $i | tr -d "'"`; done After executing this command nothing is renamed. Do you know what's wrong ...
5
votes
4answers
2k views

Recursively rename subdirectories that match a regex

I have a media server with a folder called Series. (/media/Expansion2/Series/) In it, I have (surprise!) TV series. These are just the show names, e.g., /media/Expansion2/Series/The Big Bang Theory/ ...
2
votes
3answers
478 views

Rename a lot of files with all types of characters, with POSIX portability

Sometimes I need to rename all the files (the renaming convention follows later) in a directory where the filename is always in the form of 'filenamename.extension' (extension always exists and ...
1
vote
3answers
526 views

How to move files into newly created directory on condition in shell/perl

It was a mess of music files and directory. It is needed to perform the below operation over multiple directories at once: If the directory contains ".jpg" files, then create a new directory ...
1
vote
3answers
1k views

How can we rename a file with semi-colon as part of the filename?

I tried to rename all file with extension "XLS;1" to "XLS" but it just didn't work. I tried the following in cygwin in windows xp and they don't work: mv *.XLS;1 *.XLS mv *.XLS\;1 *.XLS mv ...
4
votes
6answers
3k views

Linux script or program to shorten filenames

I haven't had much success in finding a Linux version of namemangler, which I need to rename 1000 of files so they are readable on Windows. Does anyone know of a Linux program that can do this? If ...
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
813 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
627 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, ...
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 ...
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.
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
376 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
2answers
301 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 ...