BatMan22 Posted September 6, 2017 Share Posted September 6, 2017 (edited) So I'm trying to create a program that looks at all the files in a directory, and renames them according to creation date + 01/02/03/04/05/06 ect ect in the format YYMMDDC01/YYMMDDC02/YYMMDDC03/YYMMDDC04/ect ect Also if POSSIBLE, I would like it to ignore any file that is older then a week old but lets call that a 'bonus' function. This is what I have now and am kinda stuck on what to do: expandcollapse popup$atrib=FileGetTime("C:\Users\Ash\Desktop\test\test.test", 1, 0) ; Shows the filenames of all files in the current directory $path = "C:\Users\Ash\Desktop\test\" $search = FileFindFirstFile("C:\Users\Ash\Desktop\test\*.*") ; Count number of files and Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Numberoffiles=0 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $Numberoffiles+=1 WEnd ; Close the search handle FileClose($search) MsgBox(0,"Number of files",$Numberoffiles) For $i = 0 to 3 - 1 ConsoleWrite($atrib[1] & @LF) Next MsgBox(0, "", $atrib[0]-2000 & $atrib[1]& $atrib[2]);ghetto but works for the next ~73 years ;RenameTest For $i= 0 to $numberoffiles-1 MsgBox(0,"Number of files",$Numberoffiles) $Numberoffiles-=1 $file = FileFindNextFile($search) FileMove($path & $file, $path & $numberoffiles, 1) Next ;FileMove ( "C:\Users\Ash\Desktop\test\" & $, "C:\Users\Ash\Desktop\test\*.test" ) Edited September 6, 2017 by BatMan22 Clarification Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted September 6, 2017 Share Posted September 6, 2017 Good morning @BatMan22 Let me understand... You are trying to read the attributes of a file, and rename that file with his creation date; this, for all the files in a folder, right? If so, it should not be so difficult Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Xenobiologist Posted September 6, 2017 Share Posted September 6, 2017 Does this help? ; Rename Files #include <Array.au3> ; Only required to display the arrays #include <File.au3> Local $re_A = _FileListToArrayRec('c:\Autoit\ForumTests\Dateisortierung\', '*.mp3', $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH) ;~ _ArrayDisplay($re_A) Local $FilesAndDate_A[UBound($re_A)][2] For $i = 0 To UBound($FilesAndDate_A) - 1 $FilesAndDate_A[$i][0] = $re_A[$i] $FilesAndDate_A[$i][1] = FileGetTime($re_A[$i], $FT_CREATED, $FT_STRING) Next ;~ _ArrayDisplay($FilesAndDate_A) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" For $i = 1 To UBound($FilesAndDate_A) - 1 _PathSplit($FilesAndDate_A[$i][0], $sDrive, $sDir, $sFileName, $sExtension) ConsoleWrite($sDrive & $sDir & $FilesAndDate_A[$i][1] & '_' & $sFileName & $sExtension & @CRLF) FileMove($FilesAndDate_A[$i][0], $sDrive & $sDir & $FilesAndDate_A[$i][1] & '_' & $sFileName & $sExtension, $FC_OVERWRITE) Next RockyStark 1 Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
SlackerAl Posted September 6, 2017 Share Posted September 6, 2017 I use Ant Renamer It's excellent, free, source code available and easy to use. It will let you do what you ask with the date/time functions. I run it from portable apps - so you don't even need privs to install / use. Problem solving step 1: Write a simple, self-contained, running, replicator of your problem. Link to comment Share on other sites More sharing options...
BatMan22 Posted September 6, 2017 Author Share Posted September 6, 2017 7 hours ago, Xenobiologist said: Does this help? ; Rename Files #include <Array.au3> ; Only required to display the arrays #include <File.au3> Local $re_A = _FileListToArrayRec('c:\Autoit\ForumTests\Dateisortierung\', '*.mp3', $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH) ;~ _ArrayDisplay($re_A) Local $FilesAndDate_A[UBound($re_A)][2] For $i = 0 To UBound($FilesAndDate_A) - 1 $FilesAndDate_A[$i][0] = $re_A[$i] $FilesAndDate_A[$i][1] = FileGetTime($re_A[$i], $FT_CREATED, $FT_STRING) Next ;~ _ArrayDisplay($FilesAndDate_A) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" For $i = 1 To UBound($FilesAndDate_A) - 1 _PathSplit($FilesAndDate_A[$i][0], $sDrive, $sDir, $sFileName, $sExtension) ConsoleWrite($sDrive & $sDir & $FilesAndDate_A[$i][1] & '_' & $sFileName & $sExtension & @CRLF) FileMove($FilesAndDate_A[$i][0], $sDrive & $sDir & $FilesAndDate_A[$i][1] & '_' & $sFileName & $sExtension, $FC_OVERWRITE) Next That's most of what I was looking for.. but.. format needs to be yymmdd, also it needs to be numbered, and to recognize files that are already done, and not do those again. Link to comment Share on other sites More sharing options...
BatMan22 Posted September 6, 2017 Author Share Posted September 6, 2017 6 hours ago, SlackerAl said: I use Ant Renamer It's excellent, free, source code available and easy to use. It will let you do what you ask with the date/time functions. I run it from portable apps - so you don't even need privs to install / use. I currently use BulkRenameUtility, it's a GREAT app and I'm fine with leaving everything alone.. but.. the idiots I work with cant even figure out how THAT is supposed to work.. I've included an example of what the files should look like in GREEN in this picture after it's done renaming. Link to comment Share on other sites More sharing options...
Xenobiologist Posted September 7, 2017 Share Posted September 7, 2017 14 hours ago, BatMan22 said: That's most of what I was looking for.. but.. format needs to be yymmdd, also it needs to be numbered, and to recognize files that are already done, and not do those again. So, do you want to extend the script with that functionality, or are fine with your tool? Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
BatMan22 Posted September 9, 2017 Author Share Posted September 9, 2017 On 9/7/2017 at 0:45 AM, Xenobiologist said: So, do you want to extend the script with that functionality, or are fine with your tool? I would love to extend it's functionality.. I really want to automate it so I don't have to deal with their calls every other day. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now