Jump to content

Recommended Posts

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
Posted

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:

Posted

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

Posted

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 :

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

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
×
×
  • Create New...