Jump to content
Sign in to follow this  

Questions regarding folder-check and shortcut-creation script

Recommended Posts


Hi there,

im new to AutoIT and i have a question regarding a script im planning to code and wheter its possible to do it with AutoIT or not. Please excuse me for my english, but its not my native language.

Now regarding the planned script:

I have 2 "main" Folders, and inside the two folders there are many other sub-folders. Some of those other folders share the exact same name across the main folders.
I would like to have the script to check if the name of a folder exists in both "main" folders. And if there is a folder in both "main" folders, put a windows-shortcut inside of such a sub-folder pointing to the folder from the other "main" folder.

Here is an example:

Main folder "1" on drive E: called "MainFolder1", sub folders inside are "Subfolder0001"; "Subfolder0002; "Subfolder0003"; "Subfolder0004"; "Subfolder0005", "Subfolder0006"; "Subfolder0007".

Main folder "2" on drive F: called "MainFolder2", sub folders inside are "Subfolder0002; "Subfolder0003"; "Subfolder0005"

The script now should check "F:MainFolder2", recognizes there are 3 folders inside:
- "F:MainFolder2Subfolder0002"

- "F:MainFolder2Subfolder0003"

- "F:MainFolder2Subfolder0005"

then it should compare it to "E:MainFolder1", to check if there are also those 3 recognized folders inside. If that is the case (and it is) it should create a windows shortcut for each of those recognized folders to the F:Mainfolder2 subfolders, ie.:

- "F:MainFolder2Subfolder0002shortcut_to_Subfolder0002.lnk" , where the shortcut "shortcut_to_Subfolder0002.lnk" should point to "E:MainFolder2Subfolder0002"

- "F:MainFolder2Subfolder0003shortcut_to_Subfolder0003.lnk" , where the shortcut "shortcut_to_Subfolder0003.lnk" should point to "E:MainFolder2Subfolder0003"

- "F:MainFolder2Subfolder0005shortcut_to_Subfolder0005.lnk" , where the shortcut "shortcut_to_Subfolder0005.lnk" should point to "E:MainFolder2Subfolder0005"

Obviously, the script should only create such a shortcut if there isn't one already. Script should run once a day, so i thought about putting it in a big while-loop with a sleep.

Further down the road i was thinking about:

- having the script to log all created shortcuts into a text-file (logfile.txt) that is auto-purged reaching specified size in Kb

- be able to autostart whenever i turn on my computer

- be able to run only a single instance at once
- having a custom info-area symbol and when clicking on it, it will open the the logfile.txt

What do you think, is that possible? And if so, where to start?

I would really like to learn that on my own, but i have no idea about how to start/write the scripts framework and what functions/commands i should use, so any help greatly appreciated.

Really thanks alot for any help regarding my planned script,

best regards Christian K

Share this post

Link to post
Share on other sites

Hi ChristianK,

  Welcome to the Forums !

That is a big meal for your first supper ;-) But all do-able in AutoIT (pretty sure didnt read it all)

Have a look at the File and Dir (directory/folder) section of the helpfile FileCopy etc...

Most of them have examples that you can use and change and play around with until you understand how they work.

Then build them together to make your script do what you want.

If you get stuck, come back and post your code and your issue and we will try to help.

Good luck


Share this post

Link to post
Share on other sites

Hello Bill, thanks alot for your help. Greatly appreciated.

I have some basic questions about the structure of that script. Should i put everything into one file? Would it be better to put all "calculations" and "match-operations" into own written functions that are then called from the main script? (if thats possible in AutoIT)?

For a basic start, i was planning to read all folder names of a specific directoy and put it into an array, doing the same for folder Nr2 and then compare both arrays for matching results. These results then stored into another 3rd array.
Is that possible at all, or do you have other ideas for the "basic structure" of the script?

Thanks alot,

best regards, Christian

Share this post

Link to post
Share on other sites

A lot of those questions will depend on how you build the script...

As you learn you will find better ways to do things but for starters I would start simple and just start testing around and see how things work.

And how close you can get to your idea with them.

Yes! An array is an excellent start have a look at this very cool tool : _FileListToArrayRec

Give it a shot...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this