하위 폴더 내의 모든 파일을 상위 폴더로 이동

하위 폴더 내의 모든 파일을 상위 폴더로 이동

나에게 이런 길이 있다고 해보자.

/x/xx/file

/x/내부의 모든 파일을 동시에 하위 폴더로 이동하고 싶습니다 . /x/가능합니까?

우분투 16.04를 사용하고 있습니다.

하위 폴더의 이름이 다르며 깊이에 관계없이 하위 폴더 내의 모든 파일 을 /x/. 어쨌든 파일이 없어야 합니다./x//x/

답변1

대상 폴더로 이동하고 다음을 실행합니다.

find . -mindepth 2 -type f -print -exec mv {} . \;

-mindepth 2현재 디렉터리를 제외하고 재귀적으로 검색 합니다 .

답변2

하위 디렉토리 수에 따라 다릅니다.

mv */* .

답변3

이 Python 스크립트는 Windows에서 작업을 수행해야 합니다.

import pyautogui
import keyboard
import time

# Pause for a few seconds to give you time to switch to the window you want to automate
time.sleep(10)
print("10sec")

while True:
    pyautogui.press('enter')
    print("Pressed Enter key")
    time.sleep(1)
    pyautogui.hotkey('ctrl', 'a')
    print("Pressed Ctrl+A keys")
    pyautogui.hotkey('ctrl', 'x')
    print("Pressed Ctrl+X keys")
    pyautogui.press('backspace')
    print("Pressed Backspace key")
    time.sleep(3)
    pyautogui.hotkey('ctrl', 'v')
    print("Pressed Ctrl+V keys")
    pyautogui.press('delete')
    print("Pressed Delete key")
    time.sleep(1)
    pyautogui.press('enter')
    print("Pressed Enter key")
    time.sleep(1)
    pyautogui.press('right')
    print("Pressed Right Arrow key")
    pyautogui.press('left')
    print("Pressed Left Arrow key")

    # Listen for the Esc key press and stop the script if detected
    if keyboard.is_pressed('Esc'):
        break

참고: 하위 폴더도 삭제됩니다.

관련 정보