troubleshooting Question

Use powershell to read a text file containing filenames to move just those files from folder A to folder B.

Avatar of paultran00
paultran00Flag for United States of America asked on
22 Comments1 Solution128 ViewsLast Modified:
powershell and Windows 7.


I have a text file request.txt containing filenames such as:

Actual filenames:
18-111 member 91-A.pdf
18-111 MD 91-A.pdf
18-222 member 91-B.pdf
18-222 MD 91-B.pdf
18-333 member 91-C.pdf
18-333 MD 91-C.pdf

QUESTION: how do I use powershell to
1) loop through request.txt and do a partial match to identify certain .pdf files to move from folder A to a specific folder B that has the same name as the last 4 characters of the filename?  

18-111 member 91-A.pdf is moved to folder 91-A.
18-111 MD 91-A.pdf is moved to folder 91-A.
18-222 member 91-B.pdf is moved to folder 91-B.
18-222 MD 91-B.pdf is moved to folder 91-B.

2) Add today's timestamp to the end of the filename in the format YYYMMDD_HHMM in 24hour format.
RESULT: If today is 3/26/2019 1:21pm.
18-111 member 91-A 20190326_1321.pdf
18-111 MD 91-A 20190326_1321.pdf
18-222 member 91-B 20190326_1321.pdf
18-222 MD 91-B 20190326_1321.pdf
Join our community to see this answer!
Unlock 1 Answer and 22 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros