Windows 7 (script): Create pre-defined folder structure
2013-08
Is it possible to create a script, which can be activated through the right-click menu in Windows, which will create a pre-defined folder structure?
Every time we get a new update at my work I have to make a new “update-record” inside a folder. Each update-folder contains exactly the same folders, more or less.
I could create an empty folder structure which I could copy each time but we’re using an older CSV repository and new folders and files have to be created because of some strange reference or ID that it gives it and has trouble separating multiple copies of folders or files.
Another issue is that my Work Laptop is “admin restricted” so I don’t have permissions to install any program, but I can run scripts (just not powershell, unfortunately, because it is not activated) and Macros.
I’m not sure if it is possible at all but it would be a real time-saver just to create a new folder structure with a click of a button.
Cheers,
- Mestika
Try this bat file (paste the code into notepad and save as a .bat file). The first line is a variable so change it to the root folder you want all to be created.
set rootDirectory = C:\Documents and Settings\username\Desktop\
cd %rootDirectory%
md test
md test\01
The above creates 1 folder on the desktop (called test) and then a subfolder called 01.
EDIT
In fact you don't even need the variable in this instance either (this does exactly the same, just with 1 line less code):
cd C:\Documents and Settings\username\Desktop\
md test
md test\01
When I install Windows Vista/7, I move some of my user folders onto a new partition (i.e. Documents, Musics, Pictures, etc.). This does not include moving the whole User directory, just some of the data folders. %AppData% remains in it's default location (%SystemDrive%\Users).
I'm getting tired of manually moving each of these folder's by changing their location under the properties dialog. Does anyone know of a way that I can script this to apply to the folders that I wish?
I usually move the folders to my separate partition and then symlink them back into the C:\Users folder. This has the advantage that legacy apps that tend to break on custom paths can access the folder as usual.
This snippet of batch script should do what you want. Note that you have to run it as Administrator for symlinking to work ( untested, YMMV ):
::Change this to the folder where you want to store your data
set DESTFOLDER="Z:\Path\on\other\partition"
::Switch to the current user's profile folder
::Change this to the folder you want to move from if you are moving another user's data
set SOURCEFOLDER="%USERPROFILE%"
pushd "%SOURCEFOLDER%"
for /d %%d in (Documents Music Pictures Videos) do
(
::Move the folder to the new partition
move "%%d" "%DESTFOLDER%\%%d"
::Symlink it back to the original location
mklink /d "%%d" "%DESTFOLDER%\%%d"
)
This is just of the top of my head, but it's similar to what I use for my Ubuntu install, where I symlink all of the subfolders of my home folder to my NTFS data partition.
Belvedere from Adam Pash at Lifehacker might be what you're looking for.
Belvedere's friendly interface to create advanced rules to move, copy, delete, rename, or open files based on their name, extension, size, creation date, and more.
Try recording an autohotkey script. It's a very powerful macro recorder for windows. Do it once and save the script.