Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filename and folder partial matching and move
#2
quick and dirty, need tweaks and checking tests but should help out of the box

Macro Macro20
Code:
Copy      Help
str s=
;ID=11059 l Title=American Eagle.jpg
;ID=11019 l Title=American Eagle.jpg
;ID=10119 l Title=American Eagle.jpg
;ID=12285 l Title=Kingdoms.jpg
;ID=12059 l Title=American Eagle.jpg
;ID=12085 l Title=Three Kingdoms.jpg
;ID=10059 l Title=American Eagle.jpg
;ID=23501 l Title=American Eagle.jpg

;input for pattern to search for
str name
int ok=inp(name "Word to find" "Word to find")

;where to search
str location
BrowseForFolder(&location "" 5)

;enum files
ARRAY(str) a
GetFilesInFolder a location "*.jpg" 0

;get jpg files
ARRAY(str) b
for _i 0 a.len
,if(find(a[_i] name 0 1)!=-1)
,,b[]=a[_i]

;create folder named by searched word
if(b.len)
,_s.from(location "\" name)
,mkdir _s

;move files matching pattern
for _i 0 b.len
,ren b[_i] _s

Hope you'll find useful....


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)