Moving files via batch script

batch script to move files based on filename
batch file to move all files from one folder to another
batch file move command
batch file to move files from one folder to another on network
batch file to move folders from one folder to another
batch file to move files from one folder to another based on date
batch move file to subfolder
batch file to move files from one server to another

I am trying to move files to directories that has the same name as the file, excluding the extension and add the word footage to the end of the directory name:

For example:

File Graduation 2014.mkv should be moved to folder Graduation 2014 Footage File Graduation 2015.mkv should be moved to folder Graduation 2015 Footage etc.

Here is what I have tried:

@echo off
 for %%A in (*.mkv) do (
   move "%%A" "%%~nA:~0,-8"
 )
 pause`

bu I get the following error:

The filename, directory name, or volume label syntax is incorrect.*

This simple solution works for me.

Here is the Folder Names as Example:

File1_ext
12345_5678
43226343_12
224356434
File2_ext
File3_ext
Folder_exc
File4_ext
Ect-Hello

Output Tree:

C:.
│   Move.bat
│
├───12345_5678
├───224356434
├───43226343_12
├───Ect-Hello
├───File1_ext
│       File1.mkv
│
├───File2_ext
│       File2.mkv
│
├───File3_ext
│       File3.mkv
│
├───File4_ext
│       File4.mkv
│
└───Folder_exc

Batch Script:

@echo off
@setlocal enabledelayedexpansion
Rem | Get File Name
FOR %%A IN (*.mkv) do (
    Set "FileExt=%%~xA"
    Set "FileName=%%~nA"

    Rem | Get Folder Name
    for /f "tokens=*" %%B in ('dir /b /a:d^| find /i "!FileName!"') do (

        Move "!FileName!!FileExt!" "%~dp0%%B"
    )
)
pause

Windows batch script to move files, bat file in advance and transfer files later at your ease. A .bat file is a well-known yet little used secret of Windows which can execute different� Moving and arranging files around on your computer can be time-consuming. In Windows 10, it is faster to create a batch file (.bat) and move multiple source files and subfolders to any destination folder. You can define the properties of such a .bat file in advance and transfer files later at your ease.

I am posting this answer only based purely this line in your question.

Trying to move files(.mkv) into folders that have the same name except for the last 8 characters.

I believe you should have simply just did this and let the script create the folder for you:

@echo off
for %%i in (*.mkv) do (
   mkdir "%%~ni Footage">nul 2>&1
   move "%%i"  "%%~ni Footage"
)
pause

or if you insist on not making the script create the folder, simply do:

@for %%i in (*.mkv) do @move "%%i"  "%%~ni Footage"

How to Create and Use a Batch File to Move Multiple Files in , General. basic command is move path+file1 newpath. create a *.bat file to batch move multiple files across multiple directories� Batch Script - MOVE - This batch command moves files or directories between directories.

I would suggest doing it in a slightly different way than others. Gerhard Barnard and John Kens suggested to make a simple for loop through all *.mkv files. However, this won't work if there are hidden files. You may have an alternative extremely general solution:

@echo off

for /F "delims=" %%A IN ('dir /b /a-d "C:\some\path\to\mkvs" *.mkv') do (
    attrib -h "%%~fA" >nul 2>&1
    if not exist "%%~dpnA Footage\" md "%%~dpnA"
    move "%%~fA" "%%~dpnA Footage\"
)

which is surely more secure since we are using full paths. The if exist may be pointless here because you can do:

@echo off

for /F "delims=" %%A IN ('dir /b /a-d "C:\some\path\to\mkvs" *.mkv') do (
    attrib -h "%%~fA" >nul 2>&1
    md "%%~dpnA" >nul 2>&1
    move "%%~fA" "%%~dpnA Footage\"
)

which means to redirect any output (errors and STDOUT) to nul, so hide them.

Digital Projects for Fondren Library / Steps to batch move files or , MOVE. Move a file from one folder to another. Syntax MOVE [options] [Source] on overwrite unless the command is being executed from within a batch script. This tutorial explains how to move files or directories to another location on a Windows system. Move files to another directory move filename destinationFolder. Example: to move file ‘data.docx’ to the folder ‘d:\backup\folder’ move data.docx d:\backup\folder\ You can also rename the file while moving it to the new location

Move - Windows CMD, I'm trying to write a batch script that will take all .png files in one location on our network and move them to another location on the network (using Windows). The default protocol is to prompt on overwrites unless MOVE command is being executed from within a batch script. Move examples move c:\windows\temp\*.* c:\temp. Move the files of c:\windows\temp to the temp directory in root, this is of course assuming you have the Windows\temp directory

[SOLVED] Batch Script to Move Files, Solution: Hello Chris, Create a bat file, the below will move all files from source to a different folder [ Only files not folders].Move I:\source\* I need to move files from one directory to another in windows, and I need to write this in a batch script. We have written a SQL job where backup files will be created every 4 hours on the D: drive and last 4 backup files will be saved and others will be deleted.

[SOLVED] Script to move files in a folder, Windows Command Line. Windows Commands, Batch files, Command prompt and PowerShell Example: to move file 'data.docx' to the folder 'd:\backup\folder' To move all files starting with letter 'A', you can use below command. move A*� Type a name for the script — for example, first_simple_batch.bat. Quick note: While batch files typically use the .bat file extensions, you may also see scripts using the .cmd or .btm file

Comments
  • There is no . between filename and extension. *.mkv.
  • @PunyTed Do you need to make these folders or do they already exist?
  • I am a bit unclear on the folder name? so the folder will be called File_mkv?
  • @PunyTed, when you're finished, deciding what the task is, can you let us know, I do not want to have to create answers then delete them again due to significant changes in your requirements.
  • still not very clear, what you really want. As your question stands right now, replacing move "%%A" "%%~nA:~0,-8" with move "%%A" "%%~nA Footage\" should do...
  • This is what I read from the post. He keeps editing it and y'all have to baby feed him for results. Sorry if this was the solution from 30 mins ago and if I missed it.
  • @JohnKens Sorry, about that re editting the post repeated I was told that the information I provided was not enough or specific. But you solution worked fine for me. Thank you.
  • @PunyTed I am honestly confused by what you really wanted.
  • @GerhardBarnard I'm sorry my initial phrasing might have left too much up to interpretation. Thanks for the effort you put in. Apologies for wasting your time.
  • ok, but I explained to you that it would be much easier to let the script do the folder creation, based on the name, simply because you will get issues when this is the case. if you had two mkv files, summer graduation 2014.mkv and summer graduation 2014 New York.mkv then john's answer will not work because it will find two matching folders. Also, your examples made no sense because they had an additional word in the beginning which was not catered for at all? Anyway, This was simply to explain to you that you should be clear on your questions to make it easier for us.
  • The folders were already made and contained other stuff like subtitle files. If making new empty folders with the same name merges them together (I'm not sure) then you are right. However your script seem to put all the .mkv files into the first folder that ends with footage instead of separating them by the prefixes. Yes, its true that john's answer will not be effective then, but my files that are going into the same folder do not have a different sulfix at the end so its fine.
  • If the addition word you are referring to is 'Moving' that is the action I want to take, its not part of the .mkv name and so I did not bold it. Once again I'm sorry for any frustration this have caused you.
  • Yes, but the word was highlighted as such, I have fixed your question, so hopefully you'll better post the next one :)
  • @PunyTed oh and fixed the script, forgot to remove the /f functions.