You can copy files or directories within irods with the icp command:
| icp -r /WCDSacc/courses/11032025/your_username/iris_data/ /WCDSacc/courses/11032025/your_username/iris_data_copy
|
Extra assignment: Check what the difference is between copying from /WCDSacc/courses/11032025/your_username/iris_data/ or from /WCDSacc/courses/11032025/your_username/iris_data
Or just copy one file:
| icp /WCDSacc/courses/11032025/your_username/iris_data/iris.data /WCDSacc/courses/11032025/your_username/iris_data/iris.data_copy
|
Copying data inside irods is not possible with iBridges. You need to upload the files again to a new folder.
You can copy a directory with the following command:
| gocmd cp -r /WCDSacc/courses/11032025/your_username/iris_data/ /WCDSacc/courses/11032025/your_username/iris_data_copy
|
You can copy a single specific file with the following command:
| gocmd cp -r /WCDSacc/courses/11032025/your_username/iris_data/iris.data /WCDSacc/courses/11032025/your_username/iris_data/iris.data_copy
|
Copy a single file:
| from connect import connect_to_irods
from irods.exception import CollectionDoesNotExist
session = connect_to_irods()
def copy(copy_path, paste_path):
return session.data_objects.copy(copy_path, paste_path)
# Example
copy('/WCDSacc/courses/11032025/your_username/iris_data/iris.data', '/WCDSacc/courses/11032025/your_username/iris_data/iris.data_copy')
...
|
or copy an entire collection (and the data structure).
| ...
def get_or_create_collection(collection):
try:
return session.collections.get(collection)
except CollectionDoesNotExist:
print(f'CollectionDoesNotExist {collection}')
return session.collections.create(collection)
def copy_coll(collection, dest_collection):
get_or_create_collection(dest_collection)
src_coll = session.collections.get(collection)
try:
print(f'1. create coll: {dest_collection}')
for cur_coll, sub_colls, data_objs in src_coll.walk():
print(f'current coll: {cur_coll.name} {cur_coll.path}')
aa = cur_coll.path.removeprefix(src_coll.path) + '/'
print(f'removeprefix: {aa}')
print(f'sub colls: {sub_colls}')
for col in sub_colls:
print(f'creating coll: {dest_collection}{aa}{col.name} {type(col)}')
session.collections.create(f'{dest_collection}{aa}{col.name}')
print(f'data_objs: {data_objs}')
for obj in data_objs:
paste_path = dest_collection + aa + obj.name
print(f'copy obj: {obj.name} to {paste_path} . {obj.path}')
copy(obj.path, paste_path)
except Exception as e:
print(f'Error: {e}')
# Example
copy_coll('/WCDSacc/courses/11032025/your_username/iris_data', '/WCDSacc/courses/11032025/your_username/iris_data_copy')
|