LoginSignup
1
1

【bat】指定したフォルダのファイルが空ファイルとしてコピー先のフォルダに作成

Posted at
copy_as_empty_files.bat
@echo off
setlocal

rem Prompt user for source folder
set /p source_folder=Enter the source folder path: 

rem Prompt user for destination folder
set /p destination_folder=Enter the destination folder path: 

rem Check if the source folder exists
if not exist "%source_folder%" (
    echo Source folder does not exist.
    exit /b 1
)

rem Create the destination folder if it does not exist
if not exist "%destination_folder%" (
    mkdir "%destination_folder%"
)

rem Loop through each file in the source folder and create an empty file in the destination folder
for %%f in ("%source_folder%\*.*") do (
    type nul > "%destination_folder%\%%~nxf"
)

echo Files copied as empty files to %destination_folder%

endlocal

スクリプトの説明
image.png

実行方法
image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1