-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccess_dir.sh
More file actions
executable file
·47 lines (36 loc) · 1.6 KB
/
access_dir.sh
File metadata and controls
executable file
·47 lines (36 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Specify the directory you want to read
TARGET_DIR="/Users/albert/.cache/huggingface/hub/datasets--ShapeNet--ShapeNetCore/blobs"
# Output file to store the paths
OUTPUT_FILE="/Users/albert/Documents/GitHub/Human_AI_perception/output.txt"
# Clear the output file (if it exists) or create a new one
> "$OUTPUT_FILE"
# Check if the directory exists
if [ -d "$TARGET_DIR" ]; then
echo "Reading directories in: $TARGET_DIR"
# Move to the target directory
cd "$TARGET_DIR" || { echo "Failed to cd into $TARGET_DIR"; exit 1; }
# Loop through all items in the TARGET_DIR
for first_level in *; do
# Check if the item is a directory
if [ -d "$first_level" ]; then
echo "Found first-level directory: $first_level"
# Move into the first-level directory
cd "$first_level" || { echo "Failed to cd into $first_level"; continue; }
# Loop through all items in the first-level directory
for second_level in *; do
# Check if the item is a directory
if [ -d "$second_level" ]; then
echo "Found second-level directory: $second_level"
# Write the full path to the output file
echo "$first_level/$second_level" >> "$OUTPUT_FILE"
fi
done
# Move back to the previous level (TARGET_DIR)
cd ..
fi
done
echo "All paths have been written to: $OUTPUT_FILE"
else
echo "Error: Directory $TARGET_DIR does not exist."
fi