Move .X to parent folder (Windows) - windows

I have a specific structure wherein I need to move some files.
Example:
C:\Root\Projects\Project1\Draft
C:\Root\Projects\Project2\Draft
etc.
I want to move files of a specific type, in this case .pdf.
How would I go about scanning all "Draft" folders for .pdf files, and then moving them to the parent ProjectX folder and deleting the "Draft" folders?
I would prefer to have a .bat I could run for this, preferably running from C:\Root.
Being a novice, I assumed it was in the logic ballpark of:
Find files of type .pdf in folders named C:\Root\Projects\*\Draft
Move found files to ./ (parent)
Find folders in C:\Root\Projects\*\ named Draft
Delete found folders
However, I'm not exactly a wiz with commands.
Any help appreciated.

Related

Replace files in multiple folders, whose name includes destination folder name

I have very little experience with the command line and I'm trying to do something very complicated (to me).
I have a directory with A LOT of subfolders and files in them. All file names contain the parent folder name, e.g.:
Folder1
data_Folder1.csv
other_file_Folder1.csv
Folder2
data_Folder2.csv
other_file_Folder2.csv
In another folder (all in one directory), I have a new version of all the data_FolderX.csv files and I need to replace them in the original folders. I cannot give them another name because of later analyses. Is there a way to replace the files in the original folders with the new version, in the command line?
I tried this Replacing a file into multiple folders/subdirectories but didn't work for me. Given that I have many .csv files in the derectories, I don't want to replace them all, so I don't think I should do it based on the file extension. I would also like to note that the name "FolderX" contains several other _, so in principal, I want to replace the .csv file starting with data in the FolderX.
Can anyone help?
Thanks in advance!

Finding and copying files in subfolders to a unique folder giving them their path names

I need to do a bash script in order to copy all files which are in various subfolders and sub-subfolders of a main directory to a unique another folder while giving them a new name indicating their source.
Source paths and files are like:
MainDir/SubFolderX/SubSubFolderXY/fileZ.dat
MainDir/UnknowName../AnotherUnknowName../AnyFile.anyExtension
... Etc
Destination folder with renamed files would be:
NewDir/SubFolderX_SubSubFolderXY_fileZ.dat
NewDir/UnknowName.._AnotherUnknowName.._AnyFile.anyExtension
Etc
What I know is that there is only 2 levels but the names of the subfolders, the subsubfolders, the files, and their extensions could be anything.

Copy directories if their subdirectories contain "connect.txt"

I want to copy multiple directories from one location to another location only if any of the subdirectories of those contain connect.txt file in them.
Example:
ANIMAL\DOG\CONNECT.TXT
PLANET\EARTH\CONNECT.TXT
SYSTEM\USER\ADMIN.TXT
Then I ONLY want to copy ANIMAL & PLANET directories to C:\DESKTOP.
move *\*\connect.txt C:\Desktop
This uses a regular expression which would work if you're really wanting to look only under the subdirectories of all directories at some location.

I'm looking for a script that will rename files and place them in a new folder

Essentially what I am looking to create is a script that will rename files in a folder, create a new folder with a specific name and place the renamed file in that new folder.
So, for instance, let's say that I had 2 files called:
test-spa.txt
test-ger.txt
I would then want to create 2 folders called spa and ger, respectively, place the appropriate file into each folder then rename the file by removing the language component; the resulting files in each folder would be test.txt.
Thanks,
Jaime
So here is the simple solution I came up with to create folders and place specific files in them. So long as I have the bat file in the same folder it works great:
#echo off
md spa ger
move file.txt EN\file.txt
move file-spa.txt spa\file.txt
move file-ger.txt ger\file.txt
I'm wondering if there is something missing that may cause an issue, such as specifying that this should only work in the current directory?

How to ignore _vti_cnf and _vti_pvt folders in the nominated folder and all sub-folders of nominated folder?

I have this in my .gitignore file located in the root of my repository:
# Expression Web tracking files
/Help/_vti_cnf
/Help/_vti_pvt
But it turns out I need to ignore these two folders in any sub folder of Help or below. See:
How do I modify it to do that?
There is no path which starts with /Help/_vti_cnf, thus no files are ignored. Change to /Help/PublisherDatabase/_vti_cnf, /Help/*/_vti_cnf (all direct subfolders contining _vti_cnf), /Help/**/_vti_cnf (all subfolders containing _vti_cnf) or _vti_cnf (ignore _vti_cnf everywhere).
For more information see https://git-scm.com/docs/gitignore

Resources