Jump to content

Create Shortcut For all files in a directory with icons


Recommended Posts

Hi all ,I am a beginner in this language :sweating:

I'm trying to make a code that Creat Shortcut for all files in a directory

I tried to use

$K = 'directory'

   $S = _FileListToArray($K), "*.*", 1)

But it did not work & i couldnt finish the code :( please help me

Edited by Natalia96
Link to comment
Share on other sites

Natalia96

  Welcome to the Forums !

Here is the FileListToArray from the help file change a little to produce your request:

#include <File.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; List all the files and folders in the desktop directory using the default parameters.
    Local $aFileList = _FileListToArray(@DesktopDir & "\test", "*", 1, True)          ;======CHANGED
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
    ; Display the results returned by _FileListToArray.
    _ArrayDisplay($aFileList, "$aFileList")
;===================================================================
    For $i = 1 To $aFileList[0]                               ;LOOP THROUGH THE ARRAY AND CREATE SHORTCUTS
        FileCreateShortcut($aFileList[$i], $aFileList[$i])
    Next
;===================================================================
EndFunc   ;==>Example

Let us know if you have any questions...

Bill

Link to comment
Share on other sites

I just noticed your request about the icons:

This is also possible in the FileCreatShortcut Parameters ^_^

Also have a look at the Directory Macros to point to your "C:UsersUsernameDocuments"

@MyDocumentsDir

Edited by l3ill
Link to comment
Share on other sites

Natalia96

  Welcome to the Forums !

Here is the FileListToArray from the help file change a little to produce your request:

#include <File.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; List all the files and folders in the desktop directory using the default parameters.
    Local $aFileList = _FileListToArray(@DesktopDir & "\test", "*", 1, True)          ;======CHANGED
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
    ; Display the results returned by _FileListToArray.
    _ArrayDisplay($aFileList, "$aFileList")
;===================================================================
    For $i = 1 To $aFileList[0]                               ;LOOP THROUGH THE ARRAY AND CREATE SHORTCUTS
        FileCreateShortcut($aFileList[$i], $aFileList[$i])
    Next
;===================================================================
EndFunc   ;==>Example

Let us know if you have any questions...

Bill

 

Thank u I tried it but i didn't got any shortcut :sweating:  It didn't wok :

Link to comment
Share on other sites

This (for instance) will send them to the desktop:

needs this include to work
#include <WinAPIShPath.au3>
;===================================================================
    For $i = 1 To $aFileList[0]                               ;LOOP THROUGH THE ARRAY AND CREATE SHORCUTS
        $fileName = _WinAPI_PathStripPath($aFileList[$i])
        FileCreateShortcut($aFileList[$i], @DesktopDir & "\" & $fileName)
    Next
;===================================================================
Edited by l3ill
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...