![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Directory Creation problem | namishtiwari | Shell Programming and Scripting | 1 | 02-05-2008 08:04 AM |
| VI questions : mass changes, mass delete and external insert | Browser_ice | AIX | 1 | 12-13-2006 04:20 AM |
| creation of unwanted directory | mridula | High Level Programming | 6 | 10-05-2005 11:40 AM |
| directory creation | sveera | UNIX for Advanced & Expert Users | 4 | 05-17-2005 01:06 PM |
| Remote directory creation | srinivay | UNIX for Advanced & Expert Users | 5 | 11-05-2004 05:56 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I have a couple thousand data files that all have to have there own directory named exactly the same as the file name. Then the file needs to be moved to that directory. For example files test1.mat, test2.mat, test3.mat in directory X need to have directories test1, test2, test3 created underneath X and then the corresponding files moved into there respective directory. Just for you information the file names are much more complicated than just test1 so typing them all out would be time consumming. Is there a way that I could write a script or something that could read the file names, create all the directories, and move all the files at once.
I am not very experienced in the Unix enviroment so any help would be appreciated. If it helps Matlab is installed on the Unix Machine. |
|
||||
|
Ok I tried both of your suggestions and neither worked exactly. There were a couple of problems with
Code:
for file in `ls` do mkdir -p $file mv $file $file/ done Code:
for file in *.mat do mkdir -p destination/$file mv $file destination/$file done Thanks in advance. |
|
||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|