Total beginner. I am learning Powershell bit by bit as the need arises.<\/p>\n
Trying to organize all files in one folder to another with a new sub-folder structure. I have a list of all the files with paths in the old folder, and I have assigned the new path and sub-folder to which each file must move. I am testing a script by trying to move one file at a time to get the hang of the right syntax. This one is not working.<\/p>\n
Get-ChildItem –Path C:\\Users\\TOM\\Documents\\HouseBuy\\pigsty.docx | Move-Item -Destination C:\\Users\\TOM\\Documents\\HomeReno\\<\/p>\n
Can someone please help by picking this apart and telling me the right syntax?<\/p>","upvoteCount":8,"answerCount":3,"datePublished":"2022-02-06T10:19:48.000Z","author":{"@type":"Person","name":"spiceuser-5xkju","url":"https://community.spiceworks.com/u/spiceuser-5xkju"},"suggestedAnswer":[{"@type":"Answer","text":"
Total beginner. I am learning Powershell bit by bit as the need arises.<\/p>\n
Trying to organize all files in one folder to another with a new sub-folder structure. I have a list of all the files with paths in the old folder, and I have assigned the new path and sub-folder to which each file must move. I am testing a script by trying to move one file at a time to get the hang of the right syntax. This one is not working.<\/p>\n
Get-ChildItem –Path C:\\Users\\TOM\\Documents\\HouseBuy\\pigsty.docx | Move-Item -Destination C:\\Users\\TOM\\Documents\\HomeReno\\<\/p>\n
Can someone please help by picking this apart and telling me the right syntax?<\/p>","upvoteCount":8,"datePublished":"2022-02-06T10:19:48.000Z","url":"https://community.spiceworks.com/t/move-item/824243/1","author":{"@type":"Person","name":"spiceuser-5xkju","url":"https://community.spiceworks.com/u/spiceuser-5xkju"}},{"@type":"Answer","text":"
I think a good option here is either to use get-content or import-csv. In my example, I’m using get content and a TXT file instead of a word DOC.
\nGet-content is piped to foreach-object which moves each file.<\/p>\n
The example of the contents of the TXT would look like so:<\/p>\n
C:\\path\\filename.txt
\nC:\\path\\filename1.jpg
\nC:\\path2\\filename.pdf<\/p>\n
get-content 'C:\\Users\\TOM\\Documents\\HouseBuy\\pigsty.txt' | % {Move-Item $_ -Destination C:\\Users\\TOM\\Documents\\HomeReno\\}\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2022-02-06T10:44:02.000Z","url":"https://community.spiceworks.com/t/move-item/824243/2","author":{"@type":"Person","name":"jrp78","url":"https://community.spiceworks.com/u/jrp78"}},{"@type":"Answer","text":"Welcome to the community. If you run this by itself, do you get an output?<\/p>\n
Get-ChildItem –Path C:\\Users\\TOM\\Documents\\HouseBuy\\pigsty.docx\n<\/code><\/pre>\nDoes the destination path already exist? You can verify it by running this:<\/p>\n
Test-Path -Path \"C:\\Users\\TOM\\Documents\\HomeReno\\\"\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2022-02-07T13:36:40.000Z","url":"https://community.spiceworks.com/t/move-item/824243/3","author":{"@type":"Person","name":"Evan7191","url":"https://community.spiceworks.com/u/Evan7191"}}]}}