How to create folders using file names and then move files into folders?
Tag : python , By : Fenix Drakken
Date : March 29 2020, 07:55 AM
this will help gregseth's answer will work, just replace trim with xargs. You could also eliminate the if test by just using mkdir -p, for example: for f in *.txt; do
band=$(echo "$f" | cut -d'-' -f1 | xargs)
mkdir -p "$band"
mv "$f" "$band"
done
|
Need a script to create folders based on file names, and auto move files
Date : March 29 2020, 07:55 AM
around this issue I need a batch file (for Windows) that I can run that will take a (very) large number of files, and place them in their own folders. , Edited to use path specified in comment @echo off
pushd D:\Video
for %%F in (*.mkv) do (
2>nul md "%%~nF"
>nul move /y "%%~nF*.*" "%%~nF"
)
popd
|
PowerShell Script to move folders from A to B based on names
Date : March 29 2020, 07:55 AM
wish of those help Im looking for a PS script that will move a folder and/or folders with a specific string in the folder name (in this case S0) to another folder containing something specific (in this case (-= Shows) Get-ChildItem S:\Downloads\*S0* | Move-Item -Destination S:\Shows
|
Script to move through multiple folders and copy only files with specific ext to another single folder
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You would want to use os.walk to walk your directory tree. Then, for each file, use os.path.splitext to get the extension. Note that splitext will return the basename, and extension. Then use shutil.copy to copy to your target directory. import os
import os.path
import shutil
for root, dir, files in os.walk('/'):
for ffile in files:
if os.path.splitext(ffile)[1] in ('.mp3', '.mp4'):
src = os.path.join(root, ffile)
shutil.copy(src, [YOUR_TARGET_DIR])
|
A script to copy files from folders with a specific file and folder names
Tag : regex , By : JackIT
Date : March 29 2020, 07:55 AM
Any of those help First, I should mention that have a windows machine. , This should give you an idea how to do it: @echo off& setlocal
for /d %%d in ("%~1\*.*") do set dir=%%d& call :next_dir %2
exit /b
:next_dir
for /f "delims=0123456789" %%i in ("%dir:~-4%") do exit /b
copy /y "%dir%\*until*.*" %1 | find "until"
|