Jump to content

XorpiZ

Members
  • Posts

    4
  • Joined

  • Last visited

XorpiZ's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanks! That did the trick! :-) I have a textfile containing anything from 1 to 300 hundred filenames, each on their own line. I need the script to read each line from the textfile and then delete any file matching that filename in the folder that the user selects. I couldn't get it to work by passing the handle to FileDelete, but giving it an absolute path worked. I'm a bit curious as to why it didn't need an absolute path when working with local files though, but I guess that's one of the big mysteries of life! :-)
  2. Hi, and thanks! :-) I just replaced it with "FileFindNextFile", and now I do get results that match my expectations. But FileDelete doesn't do anything now If $filesearch <> -1 Then;Check if match found FileDelete("*" & $line & "*");Delete any matching files $counter += 1 Endif
  3. Just a follow up - If I manually write the filename - FileDelete($folder & "filename.txt") it works just fine, so it could perhaps be the FileFindFirstFile that's having issues searching on a mapped drive?
  4. Hi, I've developed a small script that reads several lines from a textfile and then deletes any files matching those lines from a specific folder. It works splendidly on my local disk, but when I try running it on a mapped network-drive it's unable to delete any files. If I run the script on ie. c:testfolder FileFindFirstFile will return a "handle" if a match is found. If I run the script on M:testfolder (M: is a mapped drive from our server) it will always return -1. I have full rights to the folder. Any ideas? I realize it's not 'comme il faut' to post a question as your first post on a forum.. but I'm really curious as to why it's not working :-) Also, the code below isn't beautiful.. :-) BR, Thomas #include <File.au3> $file = FileOpenDialog("Choose the file containing the list", "c:\", "Text files (*.txt)"); FileOpen($file, 0); Open the file $folder = FileSelectFolder("Choose the folder containing the files", "") Local $search = FileFindFirstFile($folder & "\*.*"); Make a list of files MsgBox(0, "", $folder) If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern");If empty folder, show error Exit EndIf $counter = 0 For $i = 1 to _FileCountLines($file) ;Loop through the file $line = FileReadLine($file, $i) ;Get line $i $filesearch = FileFindFirstFile($line & "*");Search for $line + wildcard If $filesearch <> -1 Then;Check if match found FileDelete("*" & $line & "*");Delete any matching files $counter += 1 Else ;MsgBox(0, "", "Mappe: " & $folder & " --- Filnavn: " & $line) DEBUG - Can be ignored EndIf Next If $counter == 0 Then MsgBox(0, "", "No files were found!"); Else MsgBox(0, "", "Done! Deleted " & $counter & " unique files.") EndIf FileClose($file)
×
×
  • Create New...