Mi objetivo
Organizo mis proyectos en carpetas. Todas estas carpetas viven en mi carpeta Completed projects
. Estoy empezando a archivarlos en una carpeta Archived Projects
, y quiero archivarlos en subcarpetas por cliente. Siempre uso el nombre del cliente en el nombre de la carpeta del proyecto. Por ejemplo, tengo carpetas de proyectos llamadas Appeal [May 2014] - Development
y Identity Package [2014] - Communications
. (Mis clientes internos son nombres de departamentos: Académicos, Comunicaciones, Desarrollo ...) Así es como quiero que se archiven:
Archived Projects >> Development >> Appeal [May 2014] - Development
Archived Projects >> Communications >> Identity Package [2014] - Communications
Cada carpeta de proyecto también tiene un conjunto único de subcarpetas. Quiero preservar esa estructura.
Mi enfoque
He estado seleccionando un cliente a la vez, usando este script:
#!/bin/bash
# Go to the Completed Projects folder.
cd /Volumes/communications/Projects/Completed\ Projects/
# Find a folder with a specified string (e.g. "Academics") in its name.
# Move (not copy) the folder to its corresponding sub-folder of the Archived Projects folder. (e.g. /Academics)
find . -type d | while read folder ; do
if [[ "$folder" = *Academics* ]]; then
echo "Moving $folder";
mv "$folder" /Volumes/communications/Projects/Archived\ Projects/Academics/;
fi
done
He estado llamando al script como navegando, en la Terminal, al directorio con mis scripts escribiendo cd ~/Dropbox/scripts
↩ ./move_project_academics.sh
↩
Mi problema
La coincidencia de patrones rudimentaria funciona, pero mv
está generando un error:
mv: rename /Appeal [May 2014] - Development/SUB1/SUB2 to
/dest/Archived Projects/Development/SUB2: No such file or directory.
Claramente, le estoy dando el conjunto incorrecto de instrucciones. (Aunque, curiosamente, esta secuencia de comandos ha funcionado parte del tiempo .) SUB2 no pertenece a /dest/Archived Projects/Development/
en absoluto. SUB2 debe estar anidado dentro de SUB1, que debe estar anidado dentro de la carpeta del proyecto.
Mis preguntas
¿Qué comando de shell movería una carpeta y preservaría su estructura interna? ¿Y cómo podría seleccionar una carpeta por nombre de cliente?
Por solicitud, aquí está la salida completa impresa en la Terminal:
n$ ./move_project_academics.sh
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry -
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - to /Volumes/communications/Projects/Archived Projects/Academics/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry -: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Contracts
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Contracts to /Volumes/communications/Projects/Archived Projects/Academics/Contracts: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Correspondence
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Correspondence to /Volumes/communications/Projects/Archived Projects/Academics/Correspondence: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Invoices
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Invoices to /Volumes/communications/Projects/Archived Projects/Academics/Invoices: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Planning Documents
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Planning Documents to /Volumes/communications/Projects/Archived Projects/Academics/Planning Documents: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Quotes
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Documentation/Quotes to /Volumes/communications/Projects/Archived Projects/Academics/Quotes: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry to /Volumes/communications/Projects/Archived Projects/Academics/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry/Audio Files
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry/Audio Files to /Volumes/communications/Projects/Archived Projects/Academics/Audio Files: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry/Fade Files
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry/Fade Files to /Volumes/communications/Projects/Archived Projects/Academics/Fade Files: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry/Session File Backups
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Drafts/[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry/Session File Backups to /Volumes/communications/Projects/Archived Projects/Academics/Session File Backups: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Final
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Source Files
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Source Files/Copy
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Source Files/Copy to /Volumes/communications/Projects/Archived Projects/Academics/Copy: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Source Files/Design
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Source Files/Design to /Volumes/communications/Projects/Archived Projects/Academics/Design: No such file or directory
Moving ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Source Files/RAW
mv: rename ./[2013.04.05] - Audio - Academics - Course - Stephanie Hubach - Disability Ministry - /Source Files/RAW to /Volumes/communications/Projects/Archived Projects/Academics/RAW: No such file or directory