Skip to main content
added 55 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this (in Bash, I didn't pick up the mention of zsh there) :

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline (Bash/ksh/zsh, not POSIX)
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Or use for f in "/Users/Ben/Pictures/Stock Illustrations"/**/*; do ... in Bash (with shopt -s globstar), ksh or zsh (with some variations in specifics between the shells.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this:

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline (Bash/ksh/zsh, not POSIX)
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Or use for f in "/Users/Ben/Pictures/Stock Illustrations"/**/*; do ... in Bash (with shopt -s globstar), ksh or zsh (with some variations in specifics between the shells.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this (in Bash, I didn't pick up the mention of zsh there) :

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline (Bash/ksh/zsh, not POSIX)
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Or use for f in "/Users/Ben/Pictures/Stock Illustrations"/**/*; do ... in Bash (with shopt -s globstar), ksh or zsh (with some variations in specifics between the shells.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

added 26 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this:

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline (Bash/ksh/zsh, not POSIX)
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Or use for f in "/Users/Ben/Pictures/Stock Illustrations"/**/*; do ... in Bash (with shopt -s globstar), ksh or zsh (with some variations in specifics between the shells.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this:

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Or use for f in "/Users/Ben/Pictures/Stock Illustrations"/**/*; do ... in Bash (with shopt -s globstar), ksh or zsh (with some variations in specifics between the shells.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this:

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline (Bash/ksh/zsh, not POSIX)
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Or use for f in "/Users/Ben/Pictures/Stock Illustrations"/**/*; do ... in Bash (with shopt -s globstar), ksh or zsh (with some variations in specifics between the shells.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

added 178 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this:

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Or use for f in "/Users/Ben/Pictures/Stock Illustrations"/**/*; do ... in Bash (with shopt -s globstar), ksh or zsh (with some variations in specifics between the shells.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this:

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

FILES=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in "$FILES"

As in the linked post, $FILES here is a single string containing all the filenames. With enough files, it's too long for a single filename. With just a few names, you'd be attempting to access a file with embedded newlines in the name.

Here, you'd be better off by having find call pstopf itself, e.g.

$ find "/Users/Ben/Pictures/Stock Illustrations" -type f -print -exec pstopdf {} \;

If you want to use a shell loop over find's output, you'd have to do something like this:

set -f      # disable globbing
IFS=$'\n'   # set IFS to just the newline
files=$(find "/Users/Ben/Pictures/Stock Illustrations" -type f)
for f in $files; do
    echo "$f"
    pstopdf "$f"
done

Or use find ... -print0 | while IFS= read -r -d '' f; do ...; done in Bash.

Or use for f in "/Users/Ben/Pictures/Stock Illustrations"/**/*; do ... in Bash (with shopt -s globstar), ksh or zsh (with some variations in specifics between the shells.

Both shell solutions would have issues with filenames containing newlines, which I hope you don't have, but which sadly are allowed filenames.

added 8 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
Loading
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
Loading