Old 3rd September 2017, 12:53   #1
MyPC8MyBrain
Member
 
Join Date: Nov 2015
Posts: 73
Question Moving files with wildcard names in loop

HI guys
i need little help creating a loop that moves files from one dir to another,
after changing dir i want to find all files starting with ftm*.txt
and move them to another dir (keeping the original file names),

i thought this should work; obviously it doesn't

PHP Code:
          ClearErrors
          setoutpath 
"$INSTDIR\"
          
${DoUntil} ${Errors}
          
${If} ${FileExists} ftm*.txt pop $1
          rename "
$1" "$INSTDIR\BAK\"
          
${EndIf}
          
${Loop} 
im probably mixing things there but not sure what,

TIA
Chris
MyPC8MyBrain is offline   Reply With Quote
Old 3rd September 2017, 21:24   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,589
Use FindFirst and friends...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd September 2017, 21:31   #3
MyPC8MyBrain
Member
 
Join Date: Nov 2015
Posts: 73
Thumbs up

Thank you Anders
since i posted this i come across something i think you should recognize,
it is perfect for what im looking for if i can only figure out how to set its starting root dir instead of drive root,

PHP Code:
Unicode False
Unicode true

Function ProcessTextFiles
Exch 
$0
Push 
$1
Push 
$2
FindFirst 
$$"$0\ftm*.txt"
loop:
    
IfErrors end
    DetailPrint 
'Found "$0\$2"'
    
FindNext $$2
    
goto loop
end
:
FindClose $1
FindFirst 
$$"$0\*.*"
dirloop:
    
IfErrors dirend
    IfFileExists 
"$0\$2\*.*" 0 dirnext
    StrCmp 
$"." dirnext
    StrCmp 
$".." dirnext
    Push 
"$0\$2"
    
call ${__FUNCTION__}
dirnext:
    
FindNext $$2
    
goto dirloop
dirend
:
FindClose $1
Pop 
$2
Pop 
$1
Pop 
$0
FunctionEnd

section
push 
"$InstDir"
call ProcessTextFiles
sectionend 
how do i change starting dir in this little gem?
if i add the path like so
PHP Code:
FindFirst $$"$0\D:\Users\Administrator\Desktop\test\*.txt" 
it stops iterating through sub folders

TIA
Chris
MyPC8MyBrain is offline   Reply With Quote
Old 4th September 2017, 01:12   #4
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 853
In the section down the bottom of that code, instead of $instdir put the path you want to search, ie push "$DESKTOP\test".

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 4th September 2017, 08:47   #5
MyPC8MyBrain
Member
 
Join Date: Nov 2015
Posts: 73
YaY \ o / it works
Thank you Jason!

i also managed to get the first bit i asked about working with your advice Anders,
Thank you both Anders and Jason <3

ATB
Chris
MyPC8MyBrain is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump