Sign in to follow this  
Followers 0
Natalia96

Create Shortcut For all files in a directory with icons

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Perhaps you don't have a folder named "directory".

What language are you familiar with?

 

'directory' is the path for ex : "C:UsersUsernameDocuments"

VB.NET :thumbsup:

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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 :

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

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  
Followers 0