Batch code to read, then move files from one folder to another

santasnotreal

New member
Local time
10:16 AM
Messages
1
I'm new to batch coding, so I was hoping someone could help me out. I need to read several .txt files and search them for a specific string, lets say "key1" and "key2." If the file has key1, then it needs to be moved into directory1. If the file has key2, then it needs to be moved to directory2. There's no telling ahead of time what line the string is going to be on, so I'm guessing I could use "Find" to search for the key? Then how do I loop through all the files, read them, then sort them into the different directories?
Any help is much appreciated! :D
 

My Computer My Computer

OS
Windows 7 Professional x64
CPU
Intel Core I7-2720qm
Memory
8gb @ 1333mhz
Graphics Card(s)
Nvidia Geforce 460m GTX
Monitor(s) Displays
15.6" 1080x1920 hd
Hard Drives
Samsung 128gb ssd
I think that might be easier to do with a PowerShell script, though I'm no help on either of these subjects, I'm afraid.

Have a quick Google/Bing around for PowerShell scripting - I wouldn't imagine this is very difficult for beginners (the scripting, not Googling :p)
 

My Computer My Computer

Computer Manufacturer/Model Number
CreepinJesus Mk. IV
OS
Windows 7 Ultimate x64
CPU
Intel Core i5-2500 3.3GHz
Motherboard
Asus P8H67-M PRO
Memory
8GB DDR3 1333MHz
Graphics Card(s)
On-board
Sound Card
On-board
Monitor(s) Displays
Samsung SyncMaster BX2250 22.5" LED-backlit LCD
Screen Resolution
1920 * 1080
Hard Drives
OCZ Agility 3 120GB, SATA-III
PSU
Thermaltake Toughpower Grand TPG-650M
Case
Lian-Li PC-A04
Cooling
Standard fans. They blow.
Keyboard
Logitech K360
Mouse
Generic Logitech from the bargain-bin by the checkout
Internet Speed
Over 9000! ...Mbps.
Other Info
Chocolate digestives are my favourite biscuit.
Back
Top