| | |
Script to create directory structure
![]() |
•
•
Join Date: May 2007
Posts: 21
Reputation:
Solved Threads: 0
I have a number of files in a folder that are number as 1, 2, 3, 4, 5, 6, etc. I also have a text file in the same folder that identifies each of these numbered files and gives their path location. The text file looks like this:
1 C:\system\Apps\file1.exe
2 C:\system\Apps\file2.exe
3 C:\system\Data\file3.exe
4 C:\system\Data\file4.exe
...
I need a script that would take this text file and create the correct file directory structure. So in my example, the text file would be taken and then two folders would be created, Apps and Data. 1 and 2 would be placed in Apps and 3 and 4 would be placed in Data. And also 1 should be renamed as file1.exe, 2 should be renamed as file2.exe, etc.
Is this possible to do. I have no experience with scripting and do not even know where to start. I have a lot of files that need to be sorted like this and thought it might be faster using a script than doing it by hand. Any help is appreciated. Thanks.
1 C:\system\Apps\file1.exe
2 C:\system\Apps\file2.exe
3 C:\system\Data\file3.exe
4 C:\system\Data\file4.exe
...
I need a script that would take this text file and create the correct file directory structure. So in my example, the text file would be taken and then two folders would be created, Apps and Data. 1 and 2 would be placed in Apps and 3 and 4 would be placed in Data. And also 1 should be renamed as file1.exe, 2 should be renamed as file2.exe, etc.
Is this possible to do. I have no experience with scripting and do not even know where to start. I have a lot of files that need to be sorted like this and thought it might be faster using a script than doing it by hand. Any help is appreciated. Thanks.
You may want to include
Ex:
>nul 2>&1 at the end of the md as the script will undoubtedly list errors after creating the directory the first time.Ex:
Shell Scripting Syntax (Toggle Plain Text)
for /f "delims=." %%n in ('dir /b *.exe') do (md %%n >nul 2>&1 move *.exe %%n)
![]() |
Similar Threads
- How to configure GD (PHP)
- Zipping folders recursively (Shell Scripting)
- php.ini confusion (PHP)
- Tutorial: Create a cross-browser compatible, single-level, drop-down menu (Site Layout and Usability)
- For Pay Shell Script - Zip / FTP / Delete transactional files (Shell Scripting)
- Newbie Question - How to generate a link (PHP)
- need help with a project (Shell Scripting)
- Using Search Engine Friendly PHP URLs (PHP)
Other Threads in the Shell Scripting Forum
- Previous Thread: turn mb to gb!
- Next Thread: writing part of files and filenames to a new file
| Thread Tools | Search this Thread |





