Moving folders with the files with exceptions

Павел Майоров

I'm trying to move data from the "file" folder and exclude the Users folder. but in the end, the exception does not work.

Move-Item -Path $env:SystemDrive\$env:computername\File\* -exclude $env:SystemDrive\$env:computername\File\Users\*  -Destination $env:SystemDrive\UserOld\

It is necessary to transfer the data and exclude the Users folder.

CodeMonkeyNumber24

I tried using move-item in order to move folders while excluding a single folder and it doesnt seem like you need to include the entire path in the exclude. I tried this:

Move-Item -Path C:\Users\D.Baier\Desktop\testenvironment\Source -Exclude mit-1 -Destination C:\Users\D.Baier\Desktop\testenvironment\Target\

and it seemed to work perfectly, just threw an error which seems to be a known issue, at least as far as I understand it. The error was the following btw:

Move-Item : The Element cannot be moved, since the Element, located at "C:\Users\D.Baier\Desktop\testenvironment\Source\mit-1" does not exist.
In Line:1 Charakter:1
+ Move-Item -Path C:\Users\D.Baier\Desktop\testenvironment\Source \* -Exclu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Move-Item], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.MoveItemCommand

Hope that was helpful!

Edit: Sorry, my PC is set to German. I translated the error message as well as I can, however I doubt it is the exact same one one would get if you were to run this code on an English machine. I also apologize for any spelling mistakes I may have made.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Moving folders inside of folders

Moving files between folders in Google Cloud Storage with Google Cloud Console

Moving Files between Folders with Python 3

Moving created files between folders yields strange "Shared With Me" behavior

Moving multiple files from a single folder to multiple folders according to their name

Generating Folders based on file names and moving files to a subfolder in the generated folder

Moving media files with specific language into specific folders

Moving files between shared Dropbox folders

moving files and folders to a subfolder

finding files and moving their folders

Batch Programming: Moving Files to Folders Based on Date Modified

Moving files into folders using bash script

Moving files/folders to new structure

Moving all files of nested folders to other folder

Batch file for moving files to folders based on filenames

Powershell moving files between folders

Moving Files into Folders with Exceptions

Batch Moving files matching filenames to folders in C# or using a script

Moving files based on them being present in folders

Moving several files to different folders with same name

Moving files to folders based on creation date and foldername Python

Creating Folders and Moving Files

Nifi - Moving a pair of files between two folders

moving files to their respective folders using bash scripting

Moving files into separate folders

Moving files to folders based on a filename

moving files to equivalent folders in bash shell

Moving files to the right folders and renaming them using a batch script

Moving renamed files to folders according to their extension

TOP Ranking

HotTag

Archive