Apply iconv to all of the files in a directory

20,675
cd path-to-source-directory
find . -name "*.srt" -exec iconv -f CP1256 -t UTF-8 {} -o path-to-destination-directory/{} +

Example:

If source-directory is called SOURCE and destination-directory is called DESTINATION and both directories are located on the desktop, then path-to-source-directory is ~/Desktop/SOURCE and path-to-destination-directory is ~/Desktop/DESTINATION

Share:
20,675

Related videos on Youtube

quetzal
Author by

quetzal

Updated on September 18, 2022

Comments

  • quetzal
    quetzal over 1 year

    While trying to convert a collection of .srt files:

    iconv -f cp1256 -t utf-8 directory/* > target/*
    

    it converts all of the 22 files in the directory to one file in the target directory called *. I want the processed files to appear separately in the target directory. Can anybody help?

  • Honza
    Honza over 8 years
    find: Only one instance of {} is supported with -exec ... + :(