HugoMath
How to retrieve zip files from one folder and extract their contents to another folder?
Hello,
I am new to Elixir programming.
I’m attempting to retrieve zip files from one folder and extract their contents to another folder.
Although the code compiles without issues, I encounter the following error when executing it:
Failed to extract test1.zip because of {:EXIT, {{:badmatch, “test1.zip” …
Here is a part of the code :
for zip_file <- File.ls!(".") |> Enum.filter(&String.ends_with?(&1, ".zip")) do
case :zip.unzip(zip_file, [{:cwd, "."}]) do
{:ok, extracted_files} ->
# Filter for files with ".dcm" extension
dcm_files = Enum.filter(extracted_files, &String.ends_with?(&1, ".dcm"))
end
end
Thank you for your help
Most Liked
krasenyp
For starters, I’d add an error clause to the case so I get to see the error.
1
kokolegorille
Hello and welcome
You could use…
Path.wildcard "*.zip"
Commands that start with :atom are generally from Erlang.
Erlang uses charlists while Elixir uses binaries… that should work
:zip.unzip(to_charlist(zip_file), [{:cwd, "."}])
# Or the Elixir way...
zip_file
|> to_charlist()
|> :zip.unzip([{:cwd, "."}])
1
Popular in Questions
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size?
Thanks
New
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work.
Or rather, not char, but a substr...
New
Other popular topics
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
Hey :wave:t3: Elixir community,
I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New







