I have a folder "Folder1" that contains several subfolders. Each subfolder contains pdf files. Is there a windows command that allows me to remove all these pdf from all subfolders without specifying the names of pdf files?
First we have to access the file "Folder1" with the commande line
cd [path Folder1]
Then we excute the command :
Del /S /Q *.pdf
All the files pdf under Folder1 and its subfolders will be deleted.
Related
I have folder with lot of files like .txt .exe .jpeg .png etc. I need to copy only media files such as .jpg .png .mp4 etc to another folder. And if file with same name exists then add post fix to file name like img.png then img1.png.
I tried this using powershell shell script.
Copy-Item -Path .\b\*.jpeg -Destination .\a -Recurse
but it overrides the existing file. How can I do this using powershell.
i am using a Windows 10 64bit laptop to copy a bunch of folder and files to a SharePoint folder.
My Script is running in PowerShell.
If i try to copy the files and folders with the explorer (strg+c and strg+v) everything except .exe files are copying.
.exe files are blocked from the server.
If Robocopy is trying to copy the same set of folders and files:
First i use: Get-Credential
then: Connect-PnPOnline
and then copying with Robocopy.
If i copy the complete bunch of the folder i use following code:
ROBOCOPY $orgPath $newPath /MIR /dcopy:DAT /copy:DAT /r:0 /w:1
Robocopy is then working with this options:
*.* /S /E /DCOPY:DAT /COPY:DAT /PURGE /MIR /R:0 /W:1
If i just copy single files i use:
ROBOCOPY $orgPath $newPath $fileName /dcopy:DAT /copy:DAT /r:0 /w:1
Robocopy is then working with this options:
/DCOPY:DAT /COPY:DAT /R:0 /W:1
$orgPath = the path of the folder i want to copy (local or network drive)
$newPath = the path of the folder where i want to copy to (SharePoint)
$fileName = the file i want to copy
I just copy if the folder/file is not existing already.
With both versions i get the same result.
This is working fine. Robocopy is copying.
The folders and the most files (.xmlx .txt) are copying
The .exe files get the error 222 because the server is blocking this file. That is normal and i understand why he is doing it.
BUT:
.pdf files do not copy with robocopy. This files gives the error 64 (0x00000040).
So the server is not blocking this file. (i also can copy this file using the explorer) but all the .pdf files getting this error using robocopy.
But of course the connection is still working. robocopy is still copying further the .xmlx and .txt files.
The error is relating to the extension.
But i do not know why and i do not know how to solve the problem.
The Name of the .pdf files do not have any special caracters.
Does anyone can help me to fix the problem?
Thanks in advance
With best regards
Matze
I have a folder, folder A in a file path, inside folder A are multiple folders (folder 1, folder 2, folder 3). I want to create a Powershell script that goes to the file path where folder A is, read the names of the folders in it and create a .txt file
Inside the .txt file it would have:
folder 1
folder 2
folder 3
I'm not sure how to do this
(there shouldn't be the extra lines in between each folder name in the .txt file, I just can't figure out how to format it properly
So I figured out the solution to my problem. What I was looking for was:
c:\Windows> Get-ChildItem -Path C:\Users... -Name | Out-File -FilePath C:\Users...\test.txt
This outputs the names of the directories that I put in the path and takes them into the test.txt file
I want to extract contents of a folder out of a zip file to a different location using powershell.
zip file: archive.zip
path in zip: mypath (folder contains multiple files and subfolders)
destination: c:\destination
If I extract normally I get the folder created:
Command:Expand-Archive -Path archive.zip -DestinationPath c:\destination
Folder Created: c:\destination\mypath
I want to extract the contents of the folder into c:\destination directly.
If it is a specific requirement with the values mentioned in the OP then this should do the work
$Path='c:\temp\destination';Expand-Archive archive.zip $Path;Move-Item $Path\mypath\* $Path;rm $Path\mypath;
I used robocopy to copy just pdf's from an external hard drive and place them on our server.
source destination *.pdf
It copied over all the folders and subfolders even if there wasn't a .pdf file in the folder. Can someone help me either....
a) Delete empty folders or b) Copy over only folders and subfolders that have .pdf's in them?
Thank you!
Use the following command for copy over only folders and subfolders that have an extension in them in this case ".pdf"
ROBOCOPY sourcePath destPath *.pdf /MIR /S
This will only all files with that extensions and folders that have files with that extension and does not include empty folder.
Try using this ROBOCOPY command for deleting empty folders:
ROBOCOPY myfolder myfolder /S /MOVE
Here source and destination both are 'myfolder'.