• 돌아가기
  • 아래로
  • 위로
  • 목록
  • 댓글
질문

스크립트 mv 명령어 질문

모랄로 모랄로 127

0

9

mv -f "/volume2/Youtube/M/"*  "/volume2/Youtube/O/"

 

M 폴더 내용을 O폴더로 이동시킨다

 

/volume2/Youtube/M/폴더와  /volume2/Youtube/O/ 폴더 안에 동일한 A라는 폴더 가 있을 경우에 

 

/volume2/Youtube/M/A 에 있는  abcd 파일이    /volume2/Youtube/O/A  폴더로 이동이 안됩니다 

 

추가 옵션 조언 부탁드립니다 

 

 

폴더 트리는 

/volume2/Youtube/M/A

/volume2/Youtube/M/B

/volume2/Youtube/M/C

/volume2/Youtube/M/D

 

이런 식으로 늘어나갈 예정입니다 

 

 

 

신고공유스크랩
9
profile image 1등
너굴맨봇 2024.04.05. 09:29
안녕하세요, @모랄로님.😊
 

좋은답변을 받기위해서는 좋은 질문이 필요합니다.

유의할점⚠️

  • 예의를 지켜주세요. 답변자는 답변을 할 의무는 없습니다.
  • 질문에 대한 대부분의 답은 검색으로 찾아보실 수 있습니다.
  • 답변자가 답변을 하면서 대개 많은 경우는 다시 질문을 하는 경우가 많이 있습니다.
    • (질문의 대한 정보가 부족합니다. ~일 경우 결과물이 어떻게 됩니까? 등등)

질문방법🙏

자신의 상황을 최대한 자세히 설명해주세요.

상황이 정확하고 많을 수록 답변의 정확도가 올라갑니다. 

ex) ex) 헤놀로지라면 메인보드 모델 칩셋정보, CPU, 사용한 DSM 버전, 모델, 부수적인 추가 컨트롤러 나 랜카드 등과 어떠한 로더의 이미지를 사용했는지.(arpl-i18n, mshell), 어떤 버전을 사용했는지, 문제가있다면 어떠한것인지 스크린샷을 동반하고 에러의 경우 에러로그를 출력해서 주시면 좋습니다.

*가능하면 최신버전 OS/SW를 이용해주세요

 

답변에대한 피드백을 주세요.

정보가 질문에 모두 담겨있지않다면 대부분의 답변이 다른정보를 요구합니다.

이러한 답변에 대해 명확한 피드백을 주시면 도움이 됩니다.

profile image 3등
모랄로 글쓴이 2024.04.05. 09:53
# look 폴더 내용을 DL 폴더로 이동 시킨다
mv -f -r "/volume2/Youtube/Mortal2244/"* "/volume2/Youtube/OneDrive/"

# 1일 지난 파일 삭제
find "/volume2/Youtube/Mortal2244" -type f -mtime +1 -exec rm -rf {} \;\


find "/volume2/Youtube/Mortal2244" -empty -exec rm -rf {} \;




#/volume1/Bb/Movie_Look/*
#/volume1/Bb/Show_Look/*

# mv 이동
# cp 복사
profile image
모랄로 글쓴이 2024.04.05. 17:47
모랄로

import os
import shutil
import time

def delete_old_files(directory, days):
    current_time = time.time()
    for root, dirs, files in os.walk(directory):
        for file in files:
            file_path = os.path.join(root, file)
            if os.path.isfile(file_path):
                file_age = current_time - os.path.getmtime(file_path)
                if file_age > days * 86400:  # 60 ʰ   (Ϸ 86400)
                    os.remove(file_path)

def move_files(source_dir, destination_dir):
    for root, dirs, files in os.walk(source_dir):
        for file in files:
            source_file_path = os.path.join(root, file)
            destination_file_path = os.path.join(destination_dir, file)
            shutil.move(source_file_path, destination_file_path)

def delete_empty_folders(directory):
    for root, dirs, files in os.walk(directory, topdown=False):
        for dir in dirs:
            dir_path = os.path.join(root, dir)
            if not os.listdir(dir_path):
                os.rmdir(dir_path)

if __name__ == "__main__":
    show_dl_dir = "/volume2/Youtube/OneDrive"
    #
    movie_dl_dir = "/volume2/Movie_DL"

    # 60 ̻   
   # delete_old_files(show_dl_dir, 60)
    #delete_old_files(movie_dl_dir, 60)

    # "Look"     "Show_DL"  ̵
    move_files("/volume2/Youtube/Mortal2244", show_dl_dir)
#    move_files("/volume1/Bb/Movie_Look/", movie_dl_dir)

    #   
    delete_empty_folders("/volume2/Youtube/Mortal2244")
    
    delete_empty_folders(show_dl_dir)
    

profile image
화정큐삼 2024.04.05. 23:00
모랄로
# look 폴더 내용을 DL 폴더로 이동 시킨다
[ ! -d "/volume2/Youtube/OneDrive/" ] && mkdir -p "/volume2/Youtube/OneDrive/"
mv -vrf "/volume2/Youtube/Mortal2244/"* "/volume2/Youtube/OneDrive/"
profile image
화정큐삼 2024.04.05. 22:55
혹시 타겟쪽 디렉토리가 미리 생성되어 있지 않은 상태가 아닌가요?
mv 커맨드는 타겟디렉토리까지 리커시브하게 생성하며 복사가 안되는것으로 알고 있습니다.
cp 의 경우는 -R 옵션으로 타겟 디렉토리까지 생성하며 복사가 된다고 하네요.

댓글 쓰기 권한이 없습니다. 로그인

취소 댓글 등록

cmt alert

신고

"님의 댓글"

이 댓글을 신고하시겠습니까?

댓글 삭제

"님의 댓글"

삭제하시겠습니까?


목록

공유

facebooktwitterpinterestbandkakao story
번호 분류 제목 글쓴이 날짜 조회 추천
공지 정보 DSM 7.2v) Mshell로 헤놀로지 부트로더 빌드하기. 63 달소 23.05.29.01:57 25191 +24
공지 정보 DSM 7.2v) ARPL-i18n(rr)으로 헤놀로지 부트로더 빌드하기. 73 달소 23.05.23.23:58 26809 +23
질문 지금 시점에서 7세대 나스는 아이들 전력소비가 큰가요? 4 나와너 1일 전17:35 300 +1
정보 해놀 DSM 7.2.1-69057 Update 5로 업데이트 한 이후의 AME 3.1 활성화 관련 11 FantomD 1일 전12:47 325 +3
정보 토렌트 알림 디스코드로 받기 2 블랙앤해적 24.04.29.20:02 374 +1
5132 질문
image
묵월야(墨月夜) 1시간 전06:31 38 0
5131 질문
normal
준이건축 1일 전19:43 179 0
5130 질문
normal
나와너 1일 전17:35 300 +1
5129 질문
normal
서브어린이 1일 전15:01 118 0
5128 정보
image
FantomD 1일 전12:47 325 +3
5127 질문
normal
서브어린이 1일 전10:46 104 0
5126 질문
image
kira10 1일 전09:30 76 0
5125 질문
image
Noil 2일 전17:49 110 0
5124 질문
normal
단두대 2일 전14:41 194 0
5123 질문
normal
모프리 2일 전14:03 86 0
5122 질문
normal
모프리 2일 전11:36 145 0
5121 질문
normal
지나가는_문과생 3일 전15:13 165 0
5120 질문
image
유니파트 4일 전21:01 200 0
5119 질문
image
나스버섯 4일 전18:56 106 0
5118 질문
normal
서버왕자 4일 전09:17 97 0
5117 질문
normal
콩이아빠 5일 전21:17 440 0
5116 잡담
normal
훔친수건 5일 전19:32 575 0
5115 질문
normal
xpnol 5일 전16:04 148 0
5114 질문
image
나스버섯 5일 전13:16 204 0
5113 질문
normal
지나가는_문과생 6일 전00:13 102 0