3 posts in this topic
from the DirMove page we have:
I'm facing exactly the same issue and I need a simplest way to fix it. Could somebody take look at this code:
Func _Extract_MoveMod($p_Dir) Local $Success=0 $Files=_FileSearch($g_GameDir & '\' & $p_Dir, '*') For $f=1 to $Files If StringInStr(FileGetAttrib($g_GameDir & '\' & $p_Dir & '\' & $Files[$f]), "D") Then $Success = DirMove($g_GameDir & '\' & $p_Dir & '\' & $Files[$f], $g_GameDir, 1) Else $Success = FileMove($g_GameDir & '\' & $p_Dir & '\' & $Files[$f], $g_GameDir & '\', 1) EndIf If $Success = 0 Then Return 0 Next $Success = DirRemove($g_GameDir & '\' & $p_Dir, 1) Return $Success EndFunc ;==>_Extract_MoveMod and tell me how I can fix this inside that function?
P.S. Why DirMove act such way is beyond my reason, especially as default and there is no flag to change it.
I want to move the content of D:\downloads to D:\pictures in my program. I found DirMove, but that causes problems...
Func Move($dest) DirMove("D:\downloads\", "D:\pictures\ABC\" & $dest) DirCreate("D:\downloads") EndFunc In a prior program exactly this piece of code did the job always properly, but now not anymore. The source path stays untouched, and a destination folder is created but empty.
I don't have a clue why it doesn't work anymore now. I've checked it dozens of times, read the article about DirMove, tried it with dozens of different combinations, but none lead to the result. I want the content of D:\downloads in D:\pictures\ABC without having another downloads folder within the destination folder or anything else... Thanks!
D:\downloads\cute_kitten.jpg should be D:\pictures\ABC\cute_kitten.jpg afterwards.
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) next Ini 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
Where is the error?
; DIRMOVE? $sDestination = "C:\Destination" $sName = "Folder" $sSource = @DesktopDir & "\" & $sName DirCreate($sDestination) DirCreate($sSource) Sleep(2000) ; Just for test DirMove($sSource, $sDestination) If @error = 0 Then ConsoleWrite("ERROR")
I see both folder, but $sSource don't move to $sDestination...
DirMove return 0
I've got a head scratcher that I am hoping someone could help me with as I'm trying to finsih up some code for our HR department that I need to put into production by Monday morning.
I have written a Autoit script that shuts down a database engine and then does a copy of the database to a folder on the database server. Unfortunately the backup space on the server is limited so I have been manually moving the backups to another server twice a week until I could find the time to automate the move of the files and folders as part of the script. Well the time to automate it is this weekend per my CIO.
Because the end users may do multiple backups in a given day, I have assigned the month-day-year_hours-minutes-seconds to a variable and I rename the initial backup folder and logfile by appending the datetime variable to them. So the folder Daily_ becomes Daily_06302012_192515 and Daily_.log becomes Daily_06302012_192515.log. Using the FileMove function I have been able to get it to move the log file but for the life of me I can't get it to move the folder . So I tried to use DirMove, but I can't get it to work either. The process runs, but the folder in still on the original server when it finishes. The code I am using to try and accomplish this is as follows:
$datetime = @MON & @MDAY & @YEAR & "_" & @hour & @min & @SEC
RunWait('PsExec \\RHP-VMS-001 robocopy "\\RHP-VMS-001\ANSOSONESTAFF\DATA" "\\Rhp-vms-001 Staff_backups\OS_Daily\daily_" /COPYALL /S /E /V /LOG+:"
RunWait(@comspec & " /c ren \\rhp-vms-001\staff_backups\OS_Daily\daily_ Daily_" & $datetime)
RunWait(@comspec & " /c ren \\Rhp-vms-001\staff_backups\OS_Daily\Daily_.log Daily_" & $datetime & ".log")
RunWait('sc \\RHP-VMS-001 start "Pervasive.SQL (relational)"', '', @SW_HIDE, 2)
RunWait('sc \\RHP-VMS-001 start "Pervasive.SQL (transactional)"', '', @SW_HIDE, 2)
DirMove("\\rhp-vms-001\staff_backups\OS_Daily\Daily_" & $datetime, "\\rhp-diskbackup\onestaff\OSTest_Daily")
MsgBox(0,"One Staff Backup", "Database engine is down please contact the IS Department")
Any help is greatly appreciated as I can;t seem to fignure out what I'm doing wrong.