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 ^__^
As a newby i need some help.
I am trying to add time stamps to file names.
But it has to do it only once. So i made a check on lenght of filename.
If filename extention and Lenght is correct it renames the file with a time stamp.
I use a ini file for settings. and extentions what needs to be renamed.
The script works but only once.
it renames all the files that are in the ini . like test.txt to text050102.txt
But when there is 2 files. Like test.txt and text050102.txt
It does not rename the test.txt file
where am i doing this wrong?
#include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> $path = IniRead("RenameFiles.ini","General","InputFolder","Error") $TimeOption = IniRead("RenameFiles.ini","General","TimeOption","Error") Local $aArray = iniReadSection("RenameFiles.ini","EXT") For $i = 1 To $aArray $search01 = FileFindFirstFile($path&"*"&$aArray[$i]) If $aArray="" Then MsgBox(0,"Error","Check RenameFiles.ini","","") Exit EndIf While 1 $File = FileFindNextFile($search01) $StringLenght= StringLen ($File) if $StringLenght= $aArray[$i] Then $FileSplit= StringSplit($File,".") $Time=FileGetTime ( $File ,$TimeOption ,0 ) If @error Then ExitLoop FileMove($path & $File, $path & $FileSplit & $Time & $Time & $Time & $aArray[$i], 0) Else ExitLoop EndIf WEnd FileClose($search01) nextIni file looks like:
[General] ;Enter folder where the files are located: ;Example C:\test\ InputFolder=C:\FileRename\ ;Enter the option you want to use, for timestamp ;0 = Last modified (default) ;1 = Created ;2 = Last accessed TimeOption=0 ;Enter Files extensions that needs a timestamp. ;FileExtention=FileNameLenght (characters) ;Example .TRX.MAU (Dont forget the leading point) ;FileNameLenght = how many characters the filename contains. Including "." ;If filename is longer or shorter it wil not rename the file. ;Example TR150730.TRX.MAU = 16 characters. [EXT] .txt=8 .log=8