Remove one level in the middle of a folder tree - windows-7

I'm using Windows 7 and would like to remove a middle level of a folder tree while maintaining the files inside those folders. For example:
C:\folder1\folder2\files
I want to remove "folder2" and keep "files".

Open a command prompt, and type:
MOVE c:\folder1\folder2\*.* c:\folder1
RMDIR c:\folder1\folder2

Related

How to move one folder back in Putty

I'm new to Putty and I have installed this on Windows.
I need to move one folder back (one folder upper) from current directory.
I tried cd.. and cd... but didn't work out.
So how to move one folder back from this directory to an upper folder ?
if you want to go to an upper directory use this command :
cd ..

Moving files of a particular File Extension from multiple folders into one specific folder

I'm only started scripting a few weeks ago and have been testing a few scripts I've put together with help from some posted on this site.
Currently I'm struggling and require some help or assistance.
I want to be able to move all files with any particular/given file extension, from within any directory, and any of their sub-directories, if they exist. I just want the files, not the folders copied.
The script works, I'm hoping for anyway, as such:
You enter the directory you want to move the files from e.g. D:\TestMove
You enter the directory you want to move the files to e.g. D:\Test
You enter the file extension of all of the files that you want to be moved from the given directory, and then sub-directories eg. .txt
If the directory you're moving them to doesn't exist, it should be created.
So in my case, I've got the directory D:\Test, with multiple sub-directories, (TestMove\Test2, etc.), and within each of those directories multiple .txt files, (for example). I want to be able to move all of the .txt files from the D:\Test directory to wherever I want.
At the moment, it's just moving the files from the directory I choose, but not from within the sub-directories.
I'm happy to get this script ripped to bits so that I can learn where I'm going wrong.
set /P DMF=Please enter Directory moving from:
set /P DMT=Please enter Directory moving too:
set /P FEX=Please enter File Extension:
if not exist %DMT% mkdir %DMT%
for %%a in (%FEX%) do (
echo Moving all %%a files to "%DMT%" ...
move "%DMF%\*%%a" "%DMT%"
)

CMD move files without knowing folder name

I'm using Windows CMD via an ANT Build file to move files from a sub-folder into a parent folder that is three levels up. The structure looks like this:
containingFolder
-tempFolder
-unkownNamedFolder
-contents.xyz
Using linux I can do this with the command mv */*.* .. with the current working directory being the temp folder. I don't know what the unknownNamedFolder will be called, but I do know that it will always be the only folder within the temp folder and that whatever content is within it needs to be extracted out to the containingFolder so that temp can be deleted and only the files will remain.
I've tried a command such as /c move *\*.* .. 2>NUL but this doesn't work.

Is there a way to copy files with a batch file to the folder that batch file is in?

So I am trying to make a batch file to sync an external hard drive.
My hard drive is not always connected to the same letter, so i cannot just make a batch file with xcopy F:\Folder1 G:\backupharddrive because G:\backupharddrivewould be variable
Is there a way to just copy to the folder the batch file is in?
Just use relative addressing, where . represents the current directory.
xcopy F:\Folder1 .
For future reference, you can also access the parent of the current folder (IOW, 1 level higher up in the directory tree) using ... This makes it handy to move up a level, or even over one. For instance, to copy files from C:\Temp\One to C:\Temp\Two, you can use
xcopy *.* ..\Two\
which means copy the files from this folder up one level and then over to the Two folder.
If you use dir from a command prompt, you'll see that in any level below the drive root you'll have items for . and .. in the list. (The root only has ., because it has no parent folder.

cmd line prompt for navigating to only folder in current folder. Windows

Suppose I have a folder called Documents, with only one folder inside, called Projects, as illustrated incredibly below...
Documents
Projects
If I'm in Documents, is there a cmd line prompt which will take me into the only available folder, in this case Projects?
So instead of using
cd Projects
I'm looking for
cd 'only available folder'
Is there a cmd for this?
In response to an answer which was deleted: I'm not looking for a list of folder contents. I'm looking to navigate directly into the only available folder.
I suppose one option is:
cd 'Tab button'
There's not really a simple command for this. Like you suggested, the best solution, and what I would do, is cdspaceTab. Strictly speaking, there is a command that satisfies your requirements, but it's not exactly easy under the fingers.
for /d %I in (*) do cd "%I"
which would loop through all directories in the current directory (ostensibly, only one), then cd to it.

Resources