File migration


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers File migration
# 1  
Old 08-08-2011
File migration

Hi:

I have a large number of image files that are named sequentially (00001.jpg, 00002.jpg, 00003.jpg, etc.) on my Macbook that I want to rename and move to a new subfolder structure. I'm creating a spreadsheet with a long list of mv commands, which is really easy to set up.

The problem I'm having is that the mv command apparently won't create the subfolders on the fly, so it looks like I'll be forced to create the folders using separate commands, unless there's a way to script this out or modify the mv command to make this work.

My unix scripting skills are severely lacking - can someone help me out?

Thanks in advance.
# 2  
Old 08-08-2011
Assuming you have your filenames in FILELIST and you in the right directory:
Code:
dir_to_move=YOURDIR_TO_MOVE
while read f; do
  dest="$dir_to_move"/`dirname "$f"`
  echo mkdir -p "$dest"
  echo mv "$f" "$dest"
done <FILELIST

If you see this command/script prints the right target on the terminal, remove echo and move your files.
# 3  
Old 08-08-2011
I think I blew the request a bit... I forgot - the sequential files are sorted into coded directories - ie: SDG0001\00001.JPG, SDG0001\00002.JPG, SDG0002\00003.JPG, etc.

I see what you're getting at - would it be possible to use a comma or tab separated input file with source and destination path/filenames, as the following, which is tab-delimited:

/Users/Steve/Desktop/Source/SDG0001/00001.JPG /Users/Steve/Desktop/Dest/1979/Photo1.JPG
/Users/Steve/Desktop/Source/SDG0001/00002.JPG /Users/Steve/Desktop/Dest/1982/Photo1.JPG
/Users/Steve/Desktop/Source/SDG0002/00003.JPG /Users/Steve/Desktop/Dest/1982/Photo2.JPG
# 4  
Old 08-08-2011
You can:
1. cp -r all your files
2. mv directories according your list.
3. mv files in this directories according your algorithm.
This is easy with a shell script but I'm too lazy to write it. Smilie I believe somebody helps you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX - FC Switch migration, SAN Migration question!

I'm New to AIX / VIOS We're doing a FC switch cutover on an ibm device, connected via SAN. How do I tell if one path to my remote disk is lost? (aix lvm) How do I tell when my link is down on my HBA port? Appreciate your help, very much! (4 Replies)
Discussion started by: BG_JrAdmin
4 Replies

2. Shell Programming and Scripting

UNIX file system to Linux file system migration

We would be migrating UNIX file system to Linux file system. We do have many directory and sub directories with files. after migrating unix to linux file system , i want to make sure all the files has been copied ? What would be the best approach to validate directory ,sub-directory and file... (1 Reply)
Discussion started by: balajikalai
1 Replies

3. UNIX for Dummies Questions & Answers

Unix file migration

Hi all, Is there a program that would make sense out of the data below; this is from MPAC unix system. I would like to get usable data that could be transferred into excel? Rich, (5 Replies)
Discussion started by: berkmillionare
5 Replies

4. UNIX for Dummies Questions & Answers

Help with information on DB migration.

Dear Admin, I am new to unix platform,please i need you to tell me and send me useful tools and advice on how to migrate an oracle DB release2 to a unix platform. your urgent responce would be appreciated. Regards, Adejuwon Odugbesi. (1 Reply)
Discussion started by: adejuwon
1 Replies

5. UNIX for Advanced & Expert Users

Migration of users

We are about to get a new server and I need to prepare for migration to the new one. This will be my first migration so I'm sure I will be learning alot. My current server is running CentOS 4.x and I want to move to a sever running Centos 5.x , thought it would make things easier. The old... (1 Reply)
Discussion started by: mcraul
1 Replies

6. UNIX for Dummies Questions & Answers

file migration windows -> unix

I've spent all of my career on windows boxes and maybe 30 secs here an there with unix. Now I find myself with a project of migrating web files (html, swf, etc) from windows to unix. I know that unix is case sensitive and there can be no spaces in file/folder names. What else do I need to... (2 Replies)
Discussion started by: mjglass
2 Replies

7. UNIX for Advanced & Expert Users

Migration

Hi all, Would appreciate advise on my situation. Currently server A is in production. Server A takes in data from Server X, does some processing and send to server Y. We are going to develop a different system in server B, something like an enhanced version of A. Server A will be retired once... (2 Replies)
Discussion started by: new2ss
2 Replies

8. UNIX for Advanced & Expert Users

Migration of binary file from Sunos 5.8 to Sunos 5.9

I have compiled binary file using "cc" on SunOS 5.8 and the same binary file i have copied to SunOS 5.9 and it is giving me core dump error.I want to know whether migration of compiled code from lower version to higer version created this problem. how can i solve this problem.I am pasting the core... (1 Reply)
Discussion started by: Arvind Maurya
1 Replies

9. UNIX for Advanced & Expert Users

migration

hi, is there any tool that i can use to update my scripts (SH scripts) form Unix to linux. please mention any useful websites. thanx in advance (2 Replies)
Discussion started by: omran
2 Replies

10. UNIX for Dummies Questions & Answers

Migration

Is it possible to migrate a UNIX program and use it in a NetWare or Windows 2000 network? I have a client that must have one of those two operating systems for the new program that they want. However, they've been using an older UNIX program for about 7 years and they want to be able to refer to... (7 Replies)
Discussion started by: refram
7 Replies
Login or Register to Ask a Question