Recently Browsing 0 members
No registered users viewing this page.
I'm trying to make a script that renames a file. I'm using FileMove but I'm really confused.
The name change is on the EXTENSION, not on the file name itself. I need to change it from ".exe_" to "exe".
FileMove is returning a 0 value and the file is clearly not renamed. Here is the relevant code.
For $index = 1 to (UBound($file_array) - 1) $new_file_name = StringTrimRight($file_array[$index], 1) FileMove($dir & "\" & $file_array[$index], $dir & "\" & $new_file_name) Next some context notes:
$file_array is the output of _FileListtoArray, and it has the correct values. $dir is known, and the script is detecting it without problem I've checked that the script is finding the correct files, and that TrimRight is working. All variables have the correct values. I've checked the file attributes, the are set to "A". Are those the correct attributes? I've tried setting the flag of FileMove to 1, 8 and 9 with the same results This was working fine 2 weeks ago when I did the last run, and I've made no changes. (I don't know why the syntax highlighting is messed, quotes are paired correctly)
I know that the help file says that FileMove will not succeed if the destination already exist... my question is, does FileMove count extensions?
hi im stuck with this I want to transfer the correct file in the existing folder
#include <File.au3> #include <AutoItConstants.au3> #include <Array.au3> $Read = "C:\New folder (3)" $FLFiles1 = _FileListToArrayRec($Read, "*.xlsx", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT, $FLTAR_NOPATH) _ArrayDisplay($FLFiles1) For $i = 0 To UBound($FLFiles1) - 1 $STR = StringTrimRight($FLFiles1[$i], 5) ConsoleWrite($STR & @CRLF) $dirS = DirGetSize($Read & "\" & $STR) If $dirS = -1 Then MsgBox(16, $STR, $dirS) Else FileMove($Read, $Read & "\" & $STR & "\" & $STR & ".xlsx") EndIf next I have 3 folders under "C:\New folder (3)" and I have 5 excel files:
C:\New folder (3)\1
C:\New folder (3)\3
C:\New folder (3)\5
1.xlsx (value of column A are all 1)
2.xlsx (value of column A are all 2)
3.xlsx (value of column A are all 3)
4.xlsx (value of column A are all 4)
5.xlsx (value of column A are all 5)
I run the above script and those excel file 1, 3, 5 was transfered in the 1, 3, and 5 folders but the value of transfered file in Column A are different and file no. 4 and 5 still remains in the folder "C:\New folder (3)".... ???
whats wrong with the script???
I am trying to create a script to clean up users' desktops by moving all desktop folders and files (except the two hidden "desktop.ini" files and a MyDesktop.lnk shortcut) to a different folder. The script below will move files but not folders. The other issue with the script is that it doesn't seem to execute from a location other than the user's desktop. I would appreciate any suggestions.
#include <File.au3> MsgBox(64, "Desktop", "Cleaning up Desktop. This box will close in 4 seconds.", 4) $Files = _FileListToArray(@DesktopDir,"*",1) For $Index = 1 To $Files If StringRight($Files[$Index],4) <> ".ini, MyDesktop.lnk" Then FileMove($Files[$Index],'F:\HOME\Desktop') EndIf Next
I'm trying to use the FileMove function to rename a bunch of text files.
Some of the files have "_1" at the end of their name, for example, "File123_1.txt". I want to remove the "_1" so it would become "File123.txt".
What I currently have...
FileMove($sSource & "\*_1.txt", $sDestination & "\*.txt")
But since I'm using a wildcard, it doesn't appear to be working. I think it's just replacing .txt with .txt. Am I going about this the wrong way? How can I use wildcards and still accomplish this?
Any help is greatly appreciated ^__^
while debugging sometimes I need the au3 stripped script with /mo parameter, so that error lines in the error message match the script. Things I use often I put inside sendto folder (shell:sendto) so I can push my file to this with right click fast. A long time I had problems with some of my scripts stripping this way because the some paths to my script included spaces (you should not do that). But here’s my solution fixing that problem:
Local $sPathToAU3Stripper = "" ; fill in the path here Local $sPath If $CmdLineRaw = "" Then ; you didn't do it with sendto $sPath = FileOpenDialog("Which file you want to AU3-strip?", "","AU3 (*.au3)", 3) If @error Then MsgBox(0, 'Error FileOpenDialog:', @error) Exit EndIf Else $sPath = $CMDLINE EndIf Local $sPath_quoted = '"' & $sPath & '"' ShellExecuteWait($sPathToAU3Stripper, $sPath_quoted & ' /mo', "", "", @SW_HIDE) I hope someone will find it useful.