0

私は現在、このスクリプトを使用していくつかのファイルを移動し、他のいくつかのコマンドを実行しています。


@echo off
setlocal disableDelayedExpansion

set "src=sourcePath"
set "dst=destinationPath"
set "search=1080p"

for /r "%src%" %%F in (*%search%*) do (
  set "full=%%~fF"
  set "name=%%~nxF"
    setlocal enableDelayedExpansion
    copy "!full!" "%dst%\!name:%search%=!"
    endlocal
)
REM call your batch script here to process the copied files

Linuxで実行できるように、誰かがそれをbashに適応させるのを手伝ってもらえますか?

4

2 に答える 2

1

すべてのファイル名の正確な形式を知らなければ難しいですが、次のようなことを試すことができます:

#!/bin/bash

files=$(find ./ -type f -name _1080p.*)

for file in ${files[@]} ; do
  new_file=$( echo $file | sed -e 's/_1080p//' )
  cp $file $new_file
  ## add further commands on $new_file here.
done

find コマンドに正規表現を追加し、必要に応じて sed 行を調整してファイルの名前を変更することで改善できます。

于 2012-06-19T14:54:23.010 に答える
0

それで、あなたのことを理解できたら、

file2=$(echo $file | sed -e "s/[1080p]//g")

cp /sourcepath/$file destinationpath/$file2

forステートメント内で機能するはずです。

于 2012-06-19T14:06:51.363 に答える